Lines Matching +full:test +full:- +full:results
2 * Copyright (c) 2015-2016 Cyril Hrubis <chrubis@suse.cz>
48 static float duration = -1;
51 static struct timespec tst_start_time; /* valid only for test pid */
53 struct results { struct
61 static struct results *results; argument
107 results = SAFE_MMAP(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, ipc_fd, 0); in setup_ipc()
110 if (tst_test->needs_checkpoints || tst_test->child_needs_reinit) { in setup_ipc()
119 if (tst_test->needs_checkpoints) { in setup_ipc()
120 tst_futexes = (char*)results + sizeof(struct results); in setup_ipc()
121 tst_max_futexes = (size - sizeof(struct results))/sizeof(futex_t); in setup_ipc()
135 if (results) { in cleanup_ipc()
136 msync((void*)results, size, MS_SYNC); in cleanup_ipc()
137 munmap((void*)results, size); in cleanup_ipc()
155 results = SAFE_MMAP(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); in tst_reinit()
156 tst_futexes = (char*)results + sizeof(struct results); in tst_reinit()
157 tst_max_futexes = (size - sizeof(struct results))/sizeof(futex_t); in tst_reinit()
164 if (!results) in update_results()
169 tst_atomic_inc(&results->skipped); in update_results()
172 tst_atomic_inc(&results->passed); in update_results()
175 tst_atomic_inc(&results->warnings); in update_results()
178 tst_atomic_inc(&results->failed); in update_results()
223 ret = TST_RET < 0 ? -(int)TST_RET : (int)TST_RET; in print_result()
229 size -= ret; in print_result()
237 size -= ret; in print_result()
239 ssize = size - 2; in print_result()
242 size -= MIN(ret, ssize); in print_result()
247 ssize = size - 2; in print_result()
250 size -= MIN(ret, ssize); in print_result()
291 if (tst_test->cleanup) in do_test_cleanup()
292 tst_test->cleanup(); in do_test_cleanup()
304 * test threads to show the same pid as their parent when CLONE_VM is in tst_vbrk_()
390 if (!tst_test->forks_child) in safe_fork()
391 tst_brk(TBROK, "test.forks_child must be set!"); in safe_fork()
406 {"h", "-h Prints this help"},
407 {"i:", "-i n Execute test n times"},
408 {"I:", "-I x Execute test for n seconds"},
409 {"C:", "-C ARG Run child process with ARG arguments (used internally)"},
419 if (!tst_test->options) in print_help()
422 for (i = 0; tst_test->options[i].optstr; i++) in print_help()
423 fprintf(stderr, "%s\n", tst_test->options[i].help); in print_help()
429 struct tst_option *toptions = tst_test->options; in check_option_collision()
448 if (!tst_test->options) in count_options()
451 for (i = 0; tst_test->options[i].optstr; i++); in count_options()
459 struct tst_option *toptions = tst_test->options; in parse_topt()
491 strcat(optstr, tst_test->options[i].optstr); in parse_opts()
588 if (results) { in do_exit()
590 printf("passed %d\n", results->passed); in do_exit()
591 printf("failed %d\n", results->failed); in do_exit()
592 printf("skipped %d\n", results->skipped); in do_exit()
593 printf("warnings %d\n", results->warnings); in do_exit()
595 if (results->passed && ret == TCONF) in do_exit()
598 if (results->failed) in do_exit()
601 if (results->skipped && !results->passed) in do_exit()
604 if (results->warnings) in do_exit()
617 if (tst_parse_kver(tst_test->min_kver, &v1, &v2, &v3)) { in check_kver()
620 tst_test->min_kver); in check_kver()
624 tst_brk(TCONF, "The test requires kernel %s or newer", in check_kver()
625 tst_test->min_kver); in check_kver()
629 static int results_equal(struct results *a, struct results *b) in results_equal()
631 if (a->passed != b->passed) in results_equal()
634 if (a->failed != b->failed) in results_equal()
637 if (a->skipped != b->skipped) in results_equal()
645 return tst_test->needs_tmpdir || in needs_tmpdir()
646 tst_test->needs_device || in needs_tmpdir()
647 tst_test->mntpoint || in needs_tmpdir()
648 tst_test->resource_files || in needs_tmpdir()
649 tst_test->needs_checkpoints; in needs_tmpdir()
656 for (i = 0; tst_test->resource_files[i]; i++) in copy_resources()
657 TST_RESOURCE_COPY(NULL, tst_test->resource_files[i], NULL); in copy_resources()
683 if (tst_test->test) in assert_test_fn()
686 if (tst_test->test_all) in assert_test_fn()
689 if (tst_test->sample) in assert_test_fn()
693 tst_brk(TBROK, "No test function speficied"); in assert_test_fn()
696 tst_brk(TBROK, "You can define only one test function"); in assert_test_fn()
698 if (tst_test->test && !tst_test->tcnt) in assert_test_fn()
701 if (!tst_test->test && tst_test->tcnt) in assert_test_fn()
702 tst_brk(TBROK, "You can define tcnt only for test()"); in assert_test_fn()
747 if (tst_test->format_device) { in prepare_device()
748 SAFE_MKFS(tdev.dev, tdev.fs_type, tst_test->dev_fs_opts, in prepare_device()
749 tst_test->dev_extra_opts); in prepare_device()
752 if (tst_test->needs_rofs) { in prepare_device()
753 prepare_and_mount_ro_fs(tdev.dev, tst_test->mntpoint, in prepare_device()
758 if (tst_test->mount_device) { in prepare_device()
759 SAFE_MOUNT(tdev.dev, tst_test->mntpoint, tdev.fs_type, in prepare_device()
760 tst_test->mnt_flags, tst_test->mnt_data); in prepare_device()
770 if (tst_test->tconf_msg) in do_setup()
771 tst_brk(TCONF, "%s", tst_test->tconf_msg); in do_setup()
777 if (tst_test->sample) in do_setup()
782 if (tst_test->needs_root && geteuid() != 0) in do_setup()
783 tst_brk(TCONF, "Test needs to be run as root"); in do_setup()
785 if (tst_test->min_kver) in do_setup()
788 if (tst_test->needs_drivers) { in do_setup()
792 for (i = 0; (name = tst_test->needs_drivers[i]); ++i) in do_setup()
797 if (tst_test->format_device) in do_setup()
798 tst_test->needs_device = 1; in do_setup()
800 if (tst_test->mount_device) { in do_setup()
801 tst_test->needs_device = 1; in do_setup()
802 tst_test->format_device = 1; in do_setup()
805 if (tst_test->all_filesystems) in do_setup()
806 tst_test->needs_device = 1; in do_setup()
813 if (tst_test->save_restore) { in do_setup()
814 const char * const *name = tst_test->save_restore; in do_setup()
822 if (tst_test->mntpoint) in do_setup()
823 SAFE_MKDIR(tst_test->mntpoint, 0777); in do_setup()
825 if ((tst_test->needs_devfs || tst_test->needs_rofs || in do_setup()
826 tst_test->mount_device || tst_test->all_filesystems) && in do_setup()
827 !tst_test->mntpoint) { in do_setup()
828 tst_brk(TBROK, "tst_test->mntpoint must be set!"); in do_setup()
831 if (!!tst_test->needs_rofs + !!tst_test->needs_devfs + in do_setup()
832 !!tst_test->needs_device > 1) { in do_setup()
837 if (tst_test->needs_devfs) in do_setup()
838 prepare_and_mount_dev_fs(tst_test->mntpoint); in do_setup()
840 if (tst_test->needs_rofs) { in do_setup()
841 /* If we failed to mount read-only tmpfs. Fallback to in do_setup()
842 * using a device with read-only filesystem. in do_setup()
844 if (prepare_and_mount_ro_fs(NULL, tst_test->mntpoint, "tmpfs")) { in do_setup()
845 tst_res(TINFO, "Can't mount tmpfs read-only, " in do_setup()
847 tst_test->needs_device = 1; in do_setup()
848 tst_test->format_device = 1; in do_setup()
852 if (tst_test->needs_device && !mntpoint_mounted) { in do_setup()
853 tdev.dev = tst_acquire_device_(NULL, tst_test->dev_min_size); in do_setup()
860 if (tst_test->dev_fs_type) in do_setup()
861 tdev.fs_type = tst_test->dev_fs_type; in do_setup()
865 if (!tst_test->all_filesystems) in do_setup()
869 if (tst_test->resource_files) in do_setup()
877 if (tst_test->setup) in do_test_setup()
878 tst_test->setup(); in do_test_setup()
887 tst_umount(tst_test->mntpoint); in do_cleanup()
889 if (tst_test->needs_device && tdev.dev) in do_cleanup()
898 if (tst_test->save_restore) in do_cleanup()
907 struct results saved_results; in run_tests()
909 if (!tst_test->test) { in run_tests()
910 saved_results = *results; in run_tests()
911 tst_test->test_all(); in run_tests()
919 if (results_equal(&saved_results, results)) in run_tests()
920 tst_brk(TBROK, "Test haven't reported results!"); in run_tests()
924 for (i = 0; i < tst_test->tcnt; i++) { in run_tests()
925 saved_results = *results; in run_tests()
926 tst_test->test(i); in run_tests()
934 if (results_equal(&saved_results, results)) in run_tests()
935 tst_brk(TBROK, "Test %i haven't reported results!", i); in run_tests()
1015 if (write(2, msg, sizeof(msg) - 1)) { \
1022 WRITE_MSG("Test timeouted, sending SIGKILL!\n"); in alarm_handler()
1023 kill(-test_pid, SIGKILL); in alarm_handler()
1027 WRITE_MSG("Cannot kill test processes!\n"); in alarm_handler()
1028 WRITE_MSG("Congratulation, likely test hit a kernel bug.\n"); in alarm_handler()
1036 alarm(results->timeout); in heartbeat_handler()
1043 WRITE_MSG("Sending SIGKILL to test process...\n"); in sigint_handler()
1044 kill(-test_pid, SIGKILL); in sigint_handler()
1057 if (results->timeout > elapsed) in tst_timeout_remaining()
1058 return results->timeout - elapsed; in tst_timeout_remaining()
1067 if (timeout == -1) { in tst_set_timeout()
1072 results->timeout = timeout; in tst_set_timeout()
1080 results->timeout = results->timeout * m + 0.5; in tst_set_timeout()
1084 results->timeout/3600, (results->timeout%3600)/60, in tst_set_timeout()
1085 results->timeout % 60); in tst_set_timeout()
1088 alarm(results->timeout); in tst_set_timeout()
1097 if (tst_test->timeout) in fork_testrun()
1098 tst_set_timeout(tst_test->timeout); in fork_testrun()
1126 tst_brk(TBROK, "Test killed! (timeout?)"); in fork_testrun()
1130 tst_brk(TBROK, "Test killed by %s!", tst_strsig(WTERMSIG(status))); in fork_testrun()
1154 tst_umount(tst_test->mntpoint); in run_tcases_per_fs()
1186 if (tst_test->all_filesystems) in tst_run_tcases()