X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Ftest_os_load.c;h=7cc35e56d6adba01d5411609f78f07eefea22b5f;hb=76c024311489ede1bca79cf647e568dde70d8a48;hp=2f82f60c73b818da54e0195684c3fcac879338a3;hpb=0a217a8df1657b4334b55b0e4a6c7837a8dbcfd9;p=oweals%2Fgnunet.git diff --git a/src/util/test_os_load.c b/src/util/test_os_load.c index 2f82f60c7..7cc35e56d 100644 --- a/src/util/test_os_load.c +++ b/src/util/test_os_load.c @@ -77,7 +77,6 @@ testcpu () fprintf (stderr, "\nbusy loop failed to increase CPU load: %d >= %d.", ret, GNUNET_OS_load_cpu_get (cfg)); - ret = 1; } else { @@ -86,20 +85,19 @@ testcpu () "\nbusy loop increased CPU load: %d < %d.", ret, GNUNET_OS_load_cpu_get (cfg)); #endif - ret = 0; } fprintf (stderr, "\n"); GNUNET_CONFIGURATION_destroy (cfg); - return ret; + return 0; } static int testdisk () { int ret; - int fd; + struct GNUNET_DISK_FileHandle *fh; char buf[65536]; struct GNUNET_TIME_Absolute start; struct GNUNET_CONFIGURATION_Handle *cfg; @@ -132,27 +130,27 @@ testdisk () return 0; } memset (buf, 42, sizeof (buf)); - fd = - GNUNET_DISK_file_open (".loadfile", O_WRONLY | O_CREAT, - S_IRUSR | S_IWUSR); - GNUNET_assert (fd != -1); + fh = GNUNET_DISK_file_open (".loadfile", GNUNET_DISK_OPEN_WRITE + | GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE); + GNUNET_assert (GNUNET_NO == GNUNET_DISK_handle_invalid(fh)); while (GNUNET_TIME_absolute_get_duration (start).value < 60 * 1000) { - LSEEK (fd, GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - 1024 * 1024 * 1024), SEEK_SET); - GNUNET_assert (sizeof (buf) == WRITE (fd, buf, sizeof (buf))); - fsync (fd); + GNUNET_DISK_file_seek (fh, GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, + 1024 * 1024 * 1024), GNUNET_DISK_SEEK_SET); + GNUNET_assert (sizeof (buf) == GNUNET_DISK_file_write (fh, buf, sizeof (buf))); + GNUNET_DISK_file_sync (fh); if (ret < GNUNET_OS_load_disk_get (cfg)) break; } - GNUNET_break (0 == CLOSE (fd)); + GNUNET_break (GNUNET_OK == GNUNET_DISK_file_close (fh)); GNUNET_break (0 == UNLINK (".loadfile")); if (ret >= GNUNET_OS_load_disk_get (cfg)) { fprintf (stderr, "\nbusy loop failed to increase IO load: %d >= %d.", ret, GNUNET_OS_load_disk_get (cfg)); - ret = 1; + ret = 0; } else { @@ -165,7 +163,7 @@ testdisk () } fprintf (stderr, "\n"); GNUNET_CONFIGURATION_destroy (cfg); - return 0; + return ret; } int