From d1d12e4b43d7c0bc0b6578f8b0f2464dd2fce3e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Sat, 7 Sep 2019 00:00:00 +0000 Subject: [PATCH] infinite_loop.c: document better, allow 0 magic value to not print Enable test by passing arguments to the test to limit loops. gem5 arm LSE: still skipped, but add a link to the master patch that was merged. --- path_properties.py | 18 ++++++++---------- userland/c/infinite_loop.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/path_properties.py b/path_properties.py index 4dec6bc..8f53ae3 100644 --- a/path_properties.py +++ b/path_properties.py @@ -474,21 +474,16 @@ path_properties_tuples = ( 'baremetal': True, }, { - 'abort.c': { - 'signal_received': signal.Signals.SIGABRT, - }, - 'assert_fail.c': { - 'signal_received': signal.Signals.SIGABRT, - }, - 'smash_stack.c': { - 'skip_run_unclassified': True, - }, + 'abort.c': {'signal_received': signal.Signals.SIGABRT}, + 'assert_fail.c': {'signal_received': signal.Signals.SIGABRT}, + # This has complex failure modes, too hard to assert. + 'smash_stack.c': {'skip_run_unclassified': True}, 'exit1.c': {'exit_status': 1}, 'exit2.c': {'exit_status': 2}, 'false.c': {'exit_status': 1}, 'file_write_read.c': {'baremetal': False}, 'getchar.c': {'interactive': True}, - 'infinite_loop.c': {'more_than_1s': True}, + 'infinite_loop.c': {'test_run_args': {'userland_args': '1 10'}}, 'malloc_max.c': {'disrupts_system': True}, 'return1.c': {'exit_status': 1}, 'return2.c': {'exit_status': 2}, @@ -500,6 +495,9 @@ path_properties_tuples = ( 'atomic.cpp': { 'test_run_args': {'cpus': 3}, # LDADD from LSE + # https://cirosantilli.com/linux-kernel-module-cheat#arm-lse + # Implemented on master: + # https://gem5-review.googlesource.com/c/public/gem5/+/19812 'gem5_unimplemented_instruction': True, }, 'count.cpp': {'more_than_1s': True}, diff --git a/userland/c/infinite_loop.c b/userland/c/infinite_loop.c index 90fb5c8..eb7e314 100644 --- a/userland/c/infinite_loop.c +++ b/userland/c/infinite_loop.c @@ -1,10 +1,15 @@ /* https://cirosantilli.com/linux-kernel-module-cheat#c * - * Loop infinitely. Print an integer whenever a period is reached: + * Loop and print an integer whenever a period is reached: * * .... - * ./infinite_loop [period] + * ./infinite_loop [period=100000000 [max=0]] * .... + * + * * period: period for printing integers to stdout + * 0 means disable printing. + * * max: Stop counting when max is reached. + * 0 means count to infinity. */ #include @@ -30,7 +35,7 @@ int main(int argc, char **argv) { j = 0; while (1) { i++; - if (i % period == 0) { + if (period != 0 && i % period == 0) { printf("%ju\n", j); j++; }