Add a simple register fuzzing test to floppy controller tests. Signed-off-by: Blue Swirl <blauwir...@gmail.com> --- tests/fdc-test.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
diff --git a/tests/fdc-test.c b/tests/fdc-test.c index 22d24ac..676b215 100644 --- a/tests/fdc-test.c +++ b/tests/fdc-test.c @@ -185,6 +185,22 @@ static void test_media_change(void) assert_bit_set(dir, DSKCHG); } +/* success if no crash or abort */ +static void fuzz_registers(void) +{ + unsigned int i; + + for (i = 0; i < 1000; i++) { + uint8_t reg, val; + + reg = (uint8_t)g_test_rand_int_range(0, 8); + val = (uint8_t)g_test_rand_int_range(0, 256); + + outb(FLOPPY_BASE + reg, val); + inb(FLOPPY_BASE + reg); + } +} + int main(int argc, char **argv) { const char *arch = qtest_get_arch(); @@ -215,6 +231,7 @@ int main(int argc, char **argv) qtest_add_func("/fdc/cmos", test_cmos); qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start); qtest_add_func("/fdc/media_change", test_media_change); + qtest_add_func("/fdc/fuzz-registers", fuzz_registers); ret = g_test_run(); -- 1.7.10
From a756100a368c84340b8a7355dde058bbc39fb7b2 Mon Sep 17 00:00:00 2001 Message-Id: <a756100a368c84340b8a7355dde058bbc39fb7b2.1338744586.git.blauwir...@gmail.com> In-Reply-To: <2a5b75851062503741f9e6a95e3087361959257d.1338744586.git.blauwir...@gmail.com> References: <2a5b75851062503741f9e6a95e3087361959257d.1338744586.git.blauwir...@gmail.com> From: Blue Swirl <blauwir...@gmail.com> Date: Thu, 17 May 2012 18:55:58 +0000 Subject: [PATCH 6/6] qtest: add a fuzz test to fdc-test Add a simple register fuzzing test to floppy controller tests. Signed-off-by: Blue Swirl <blauwir...@gmail.com> --- tests/fdc-test.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/tests/fdc-test.c b/tests/fdc-test.c index 22d24ac..676b215 100644 --- a/tests/fdc-test.c +++ b/tests/fdc-test.c @@ -185,6 +185,22 @@ static void test_media_change(void) assert_bit_set(dir, DSKCHG); } +/* success if no crash or abort */ +static void fuzz_registers(void) +{ + unsigned int i; + + for (i = 0; i < 1000; i++) { + uint8_t reg, val; + + reg = (uint8_t)g_test_rand_int_range(0, 8); + val = (uint8_t)g_test_rand_int_range(0, 256); + + outb(FLOPPY_BASE + reg, val); + inb(FLOPPY_BASE + reg); + } +} + int main(int argc, char **argv) { const char *arch = qtest_get_arch(); @@ -215,6 +231,7 @@ int main(int argc, char **argv) qtest_add_func("/fdc/cmos", test_cmos); qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start); qtest_add_func("/fdc/media_change", test_media_change); + qtest_add_func("/fdc/fuzz-registers", fuzz_registers); ret = g_test_run(); -- 1.7.2.5