testing/[sd_bench|sd_stress]: make print compatible for both 32-bit and 64-bit environment.
Use size_t and %zu in printf of sd modules to fix compilation errors in 64-bit environment. Signed-off-by: Yinzhe Wu <Yinzhe.Wu@sony.com> Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Reviewed-by: Jacky Cao <Jacky.Cao@sony.com> Tested-by: Yinzhe Wu <Yinzhe.Wu@sony.com>
This commit is contained in:
parent
5330306aca
commit
0989d820ed
@ -176,7 +176,7 @@ static void write_test(int fd, sdb_config_t *cfg, uint8_t *block,
|
|||||||
uint64_t elapsed;
|
uint64_t elapsed;
|
||||||
uint64_t total_elapsed = 0.;
|
uint64_t total_elapsed = 0.;
|
||||||
size_t total_blocks = 0;
|
size_t total_blocks = 0;
|
||||||
size_t *blocknumber = (unsigned int *)(void *)&block[0];
|
size_t *blocknumber = (size_t *)(void *)&block[0];
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Testing Sequential Write Speed...\n");
|
printf("Testing Sequential Write Speed...\n");
|
||||||
@ -277,7 +277,7 @@ static int read_test(int fd, sdb_config_t *cfg, uint8_t *block,
|
|||||||
|
|
||||||
total_elapsed = 0.;
|
total_elapsed = 0.;
|
||||||
total_blocks = 0;
|
total_blocks = 0;
|
||||||
size_t *blocknumber = (unsigned int *)(void *) &read_block[0];
|
size_t *blocknumber = (size_t *)(void *) &read_block[0];
|
||||||
|
|
||||||
for (int run = 0; run < cfg->num_runs; ++run)
|
for (int run = 0; run < cfg->num_runs; ++run)
|
||||||
{
|
{
|
||||||
@ -306,8 +306,8 @@ static int read_test(int fd, sdb_config_t *cfg, uint8_t *block,
|
|||||||
|
|
||||||
if (*blocknumber != total_blocks + num_blocks)
|
if (*blocknumber != total_blocks + num_blocks)
|
||||||
{
|
{
|
||||||
printf("Read data error at block: %d wrote:0x%04x read:0x%04x",
|
printf("Read data error at block: %zu wrote:0x%04zx "
|
||||||
(total_blocks + num_blocks),
|
"read:0x%04zx", total_blocks + num_blocks,
|
||||||
total_blocks + num_blocks, *blocknumber);
|
total_blocks + num_blocks, *blocknumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ static int read_test(int fd, sdb_config_t *cfg, uint8_t *block,
|
|||||||
{
|
{
|
||||||
if (block[i] != read_block[i])
|
if (block[i] != read_block[i])
|
||||||
{
|
{
|
||||||
printf("Read data error at offset: %d wrote:0x%02x "
|
printf("Read data error at offset: %zu wrote:0x%02x "
|
||||||
"read:0x%02x", total_blocks + num_blocks + i,
|
"read:0x%02x", total_blocks + num_blocks + i,
|
||||||
block[i], read_block[i]);
|
block[i], read_block[i]);
|
||||||
}
|
}
|
||||||
@ -353,11 +353,11 @@ static void usage(void)
|
|||||||
printf("Test the speed of an SD card or mount point\n");
|
printf("Test the speed of an SD card or mount point\n");
|
||||||
printf(CONFIG_TESTING_SD_BENCH_PROGNAME
|
printf(CONFIG_TESTING_SD_BENCH_PROGNAME
|
||||||
": [-b] [-r] [-d] [-k] [-s] [-a] [-v]\n");
|
": [-b] [-r] [-d] [-k] [-s] [-a] [-v]\n");
|
||||||
printf(" -b Block size per write (%u-%u), default %u\n",
|
printf(" -b Block size per write (%zu-%zu), default %zu\n",
|
||||||
min_block, max_block, default_block);
|
min_block, max_block, default_block);
|
||||||
printf(" -r Number of runs (%u-%u), default %u\n",
|
printf(" -r Number of runs (%zu-%zu), default %zu\n",
|
||||||
min_runs, max_runs, default_runs);
|
min_runs, max_runs, default_runs);
|
||||||
printf(" -d Max duration of a test (ms) (%u-%u), default %u\n",
|
printf(" -d Max duration of a test (ms) (%zu-%zu), default %zu\n",
|
||||||
min_duration, max_duration, default_duration);
|
min_duration, max_duration, default_duration);
|
||||||
printf(" -k Keep test file when finished, default %s\n",
|
printf(" -k Keep test file when finished, default %s\n",
|
||||||
print_bool(default_keep_test));
|
print_bool(default_keep_test));
|
||||||
@ -481,7 +481,7 @@ int main(int argc, char *argv[])
|
|||||||
block[j] = (uint8_t)j;
|
block[j] = (uint8_t)j;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Using block size = %u bytes, sync = %s\n", block_size,
|
printf("Using block size = %zu bytes, sync = %s\n", block_size,
|
||||||
print_bool(cfg.synchronized));
|
print_bool(cfg.synchronized));
|
||||||
|
|
||||||
write_test(bench_fd, &cfg, block, block_size);
|
write_test(bench_fd, &cfg, block, block_size);
|
||||||
|
@ -85,11 +85,11 @@ static void usage(void)
|
|||||||
{
|
{
|
||||||
printf("Stress test on a mount point\n");
|
printf("Stress test on a mount point\n");
|
||||||
printf(CONFIG_TESTING_SD_STRESS_PROGNAME ": [-r] [-b] [-f]\n");
|
printf(CONFIG_TESTING_SD_STRESS_PROGNAME ": [-r] [-b] [-f]\n");
|
||||||
printf(" -r Number of runs (%u-%u), default %u\n",
|
printf(" -r Number of runs (%zu-%zu), default %zu\n",
|
||||||
min_runs, max_runs, default_runs);
|
min_runs, max_runs, default_runs);
|
||||||
printf(" -b Number of bytes (%u-%u), default %u\n",
|
printf(" -b Number of bytes (%zu-%zu), default %zu\n",
|
||||||
min_bytes, max_bytes, default_bytes);
|
min_bytes, max_bytes, default_bytes);
|
||||||
printf(" -f Number of files (%u-%u), default %u\n",
|
printf(" -f Number of files (%zu-%zu), default %zu\n",
|
||||||
min_files, max_files, default_files);
|
min_files, max_files, default_files);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ static bool create_files(const char *dir, const char *name,
|
|||||||
for (size_t i = 0; i < num_files; ++i)
|
for (size_t i = 0; i < num_files; ++i)
|
||||||
{
|
{
|
||||||
char path[MAX_PATH_LEN];
|
char path[MAX_PATH_LEN];
|
||||||
snprintf(path, MAX_PATH_LEN, "%s/%s%03u", dir, name, i);
|
snprintf(path, MAX_PATH_LEN, "%s/%s%03zu", dir, name, i);
|
||||||
|
|
||||||
memset(read_bytes, 0x0, num_bytes);
|
memset(read_bytes, 0x0, num_bytes);
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ static bool remove_files(const char *dir, const char *name,
|
|||||||
for (size_t i = 0; i < num_files; ++i)
|
for (size_t i = 0; i < num_files; ++i)
|
||||||
{
|
{
|
||||||
char path[MAX_PATH_LEN];
|
char path[MAX_PATH_LEN];
|
||||||
snprintf(path, MAX_PATH_LEN, "%s/%s%03u", dir, name, i);
|
snprintf(path, MAX_PATH_LEN, "%s/%s%03zu", dir, name, i);
|
||||||
|
|
||||||
int ret = unlink(path);
|
int ret = unlink(path);
|
||||||
|
|
||||||
@ -354,7 +354,7 @@ int main(int argc, char *argv[])
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Start stress test with %u files, %u bytes and %u iterations.\n",
|
printf("Start stress test with %zu files, %zu bytes and %zu iterations.\n",
|
||||||
num_files, num_bytes, num_runs);
|
num_files, num_bytes, num_runs);
|
||||||
|
|
||||||
bytes = (char *)malloc(num_bytes);
|
bytes = (char *)malloc(num_bytes);
|
||||||
@ -386,7 +386,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
elapsed_time = get_elapsed_time_ms(&start);
|
elapsed_time = get_elapsed_time_ms(&start);
|
||||||
total_time += elapsed_time;
|
total_time += elapsed_time;
|
||||||
printf("iteration %u took %.3f ms: %s\n", i,
|
printf("iteration %zu took %.3f ms: %s\n", i,
|
||||||
elapsed_time, result ? "OK" : "FAIL");
|
elapsed_time, result ? "OK" : "FAIL");
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
|
Loading…
Reference in New Issue
Block a user