| Author | Tokens | Token Proportion | Commits | Commit Proportion |
|---|---|---|---|---|
| Thomas Weißschuh | 631 | 99.84% | 3 | 75.00% |
| Bala-Vignesh-Reddy | 1 | 0.16% | 1 | 25.00% |
| Total | 632 | 4 |
// SPDX-License-Identifier: GPL-2.0 #include <stdio.h> #include <sys/resource.h> #include <sys/prctl.h> /* Avoid any inconsistencies */ #define TH_LOG_STREAM stdout #include "kselftest_harness.h" static void test_helper(struct __test_metadata *_metadata) { ASSERT_EQ(0, 0); } TEST(standalone_pass) { TH_LOG("before"); ASSERT_EQ(0, 0); EXPECT_EQ(0, 0); test_helper(_metadata); TH_LOG("after"); } TEST(standalone_fail) { TH_LOG("before"); EXPECT_EQ(0, 0); EXPECT_EQ(0, 1); ASSERT_EQ(0, 1); TH_LOG("after"); } TEST_SIGNAL(signal_pass, SIGUSR1) { TH_LOG("before"); ASSERT_EQ(0, 0); TH_LOG("after"); kill(getpid(), SIGUSR1); } TEST_SIGNAL(signal_fail, SIGUSR1) { TH_LOG("before"); ASSERT_EQ(0, 1); TH_LOG("after"); kill(getpid(), SIGUSR1); } FIXTURE(fixture) { pid_t testpid; }; FIXTURE_SETUP(fixture) { TH_LOG("setup"); self->testpid = getpid(); } FIXTURE_TEARDOWN(fixture) { TH_LOG("teardown same-process=%d", self->testpid == getpid()); } TEST_F(fixture, pass) { TH_LOG("before"); ASSERT_EQ(0, 0); test_helper(_metadata); standalone_pass(_metadata); TH_LOG("after"); } TEST_F(fixture, fail) { TH_LOG("before"); ASSERT_EQ(0, 1); fixture_pass(_metadata, self, variant); TH_LOG("after"); } TEST_F_TIMEOUT(fixture, timeout, 1) { TH_LOG("before"); sleep(2); TH_LOG("after"); } FIXTURE(fixture_parent) { pid_t testpid; }; FIXTURE_SETUP(fixture_parent) { TH_LOG("setup"); self->testpid = getpid(); } FIXTURE_TEARDOWN_PARENT(fixture_parent) { TH_LOG("teardown same-process=%d", self->testpid == getpid()); } TEST_F(fixture_parent, pass) { TH_LOG("before"); ASSERT_EQ(0, 0); TH_LOG("after"); } FIXTURE(fixture_setup_failure) { pid_t testpid; }; FIXTURE_SETUP(fixture_setup_failure) { TH_LOG("setup"); self->testpid = getpid(); ASSERT_EQ(0, 1); } FIXTURE_TEARDOWN(fixture_setup_failure) { TH_LOG("teardown same-process=%d", self->testpid == getpid()); } TEST_F(fixture_setup_failure, pass) { TH_LOG("before"); ASSERT_EQ(0, 0); TH_LOG("after"); } TEST(exit_pass) { exit(KSFT_PASS); } TEST(exit_xpass) { exit(KSFT_XPASS); } TEST(exit_fail) { exit(KSFT_FAIL); } TEST(exit_xfail) { exit(KSFT_XFAIL); } TEST(exit_skip) { exit(KSFT_SKIP); } TEST(test_result_pass) { ksft_test_result_pass(""); } TEST(test_result_xpass) { ksft_test_result_xpass(""); } TEST(test_result_fail) { ksft_test_result_fail(""); } TEST(test_result_xfail) { ksft_test_result_xfail(""); } TEST(test_result_skip) { ksft_test_result_skip(""); } int main(int argc, char **argv) { /* * The harness uses abort() to signal assertion failures, which triggers coredumps. * This may be useful to debug real failures but not for this selftest, disable them. */ struct rlimit rlimit = { .rlim_cur = 0, .rlim_max = 0, }; prctl(PR_SET_DUMPABLE, 0, 0, 0, 0); setrlimit(RLIMIT_CORE, &rlimit); return test_harness_run(argc, argv); }
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with Cregit http://github.com/cregit/cregit
Version 2.0-RC1