Commit 1f666e52 authored by Naresh Kamboju's avatar Naresh Kamboju Committed by Shuah Khan

selftests: futex: print testcase-name and PASS/FAIL/ERROR status

Most of the tests under selftests follow a pattern for their results,
which can then be parsed easily by other external tools easily. Though
futex tests do print the test results very well, it doesn't really
follow the general selftests pattern.

This patch makes necessary changes to fix that.

Output before this patch:
futex_requeue_pi: Test requeue functionality
        Arguments: broadcast=0 locked=0 owner=0 timeout=0ns
Result:  PASS

Output after this patch:
futex_requeue_pi: Test requeue functionality
        Arguments: broadcast=0 locked=0 owner=0 timeout=0ns
selftests: futex-requeue-pi [PASS]
Signed-off-by: default avatarNaresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
parent 3c2993b8
......@@ -32,6 +32,7 @@
#include "futextest.h"
#include "logging.h"
#define TEST_NAME "futex-requeue-pi"
#define MAX_WAKE_ITERS 1000
#define THREAD_MAX 10
#define SIGNAL_PERIOD_US 100
......@@ -404,6 +405,6 @@ int main(int argc, char *argv[])
*/
ret = unit_test(broadcast, locked, owner, timeout_ns);
print_result(ret);
print_result(TEST_NAME, ret);
return ret;
}
......@@ -30,6 +30,8 @@
#include "futextest.h"
#include "logging.h"
#define TEST_NAME "futex-requeue-pi-mismatched-ops"
futex_t f1 = FUTEX_INITIALIZER;
futex_t f2 = FUTEX_INITIALIZER;
int child_ret = 0;
......@@ -130,6 +132,6 @@ int main(int argc, char *argv[])
out:
/* If the kernel crashes, we shouldn't return at all. */
print_result(ret);
print_result(TEST_NAME, ret);
return ret;
}
......@@ -32,6 +32,7 @@
#include "futextest.h"
#include "logging.h"
#define TEST_NAME "futex-requeue-pi-signal-restart"
#define DELAY_US 100
futex_t f1 = FUTEX_INITIALIZER;
......@@ -218,6 +219,6 @@ int main(int argc, char *argv[])
if (ret == RET_PASS && waiter_ret)
ret = waiter_ret;
print_result(ret);
print_result(TEST_NAME, ret);
return ret;
}
......@@ -34,6 +34,7 @@
#include "logging.h"
#include "futextest.h"
#define TEST_NAME "futex-wait-private-mapped-file"
#define PAGE_SZ 4096
char pad[PAGE_SZ] = {1};
......@@ -60,7 +61,7 @@ void *thr_futex_wait(void *arg)
ret = futex_wait(&val, 1, &wait_timeout, 0);
if (ret && errno != EWOULDBLOCK && errno != ETIMEDOUT) {
error("futex error.\n", errno);
print_result(RET_ERROR);
print_result(TEST_NAME, RET_ERROR);
exit(RET_ERROR);
}
......@@ -120,6 +121,6 @@ int main(int argc, char **argv)
pthread_join(thr, NULL);
out:
print_result(ret);
print_result(TEST_NAME, ret);
return ret;
}
......@@ -27,6 +27,8 @@
#include "futextest.h"
#include "logging.h"
#define TEST_NAME "futex-wait-timeout"
static long timeout_ns = 100000; /* 100us default timeout */
void usage(char *prog)
......@@ -81,6 +83,6 @@ int main(int argc, char *argv[])
ret = RET_FAIL;
}
print_result(ret);
print_result(TEST_NAME, ret);
return ret;
}
......@@ -36,6 +36,7 @@
#include "logging.h"
#include "futextest.h"
#define TEST_NAME "futex-wait-uninitialized-heap"
#define WAIT_US 5000000
static int child_blocked = 1;
......@@ -119,6 +120,6 @@ int main(int argc, char **argv)
}
out:
print_result(ret);
print_result(TEST_NAME, ret);
return ret;
}
......@@ -28,6 +28,7 @@
#include "futextest.h"
#include "logging.h"
#define TEST_NAME "futex-wait-wouldblock"
#define timeout_ns 100000
void usage(char *prog)
......@@ -74,6 +75,6 @@ int main(int argc, char *argv[])
ret = RET_FAIL;
}
print_result(ret);
print_result(TEST_NAME, ret);
return ret;
}
......@@ -107,7 +107,7 @@ void log_verbosity(int level)
*
* print_result() is primarily intended for functional tests.
*/
void print_result(int ret)
void print_result(const char *test_name, int ret)
{
const char *result = "Unknown return code";
......@@ -124,7 +124,7 @@ void print_result(int ret)
result = FAIL;
break;
}
printf("Result: %s\n", result);
printf("selftests: %s [%s]\n", test_name, result);
}
/* log level macros */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment