summaryrefslogtreecommitdiffstats
path: root/auto-virtserial.c
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2009-11-26 20:18:30 +0530
committerAmit Shah <amit.shah@redhat.com>2009-11-26 20:18:30 +0530
commit3fe1900b194009acc822a2bf3fc7f111d71ee2e7 (patch)
treeacfd1ba8c03e5dd481afea5cc6e66396d5c86cd0 /auto-virtserial.c
parente4275d6f944a96324e2580ed3f045defe40c9035 (diff)
downloadtest-virtserial-3fe1900b194009acc822a2bf3fc7f111d71ee2e7.tar.gz
test-virtserial-3fe1900b194009acc822a2bf3fc7f111d71ee2e7.tar.xz
test-virtserial-3fe1900b194009acc822a2bf3fc7f111d71ee2e7.zip
auto-test: Bits for enabling/disabling individual tests
Not yet configurable from the command line Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'auto-virtserial.c')
-rw-r--r--auto-virtserial.c78
1 files changed, 48 insertions, 30 deletions
diff --git a/auto-virtserial.c b/auto-virtserial.c
index b2664df..946cfb8 100644
--- a/auto-virtserial.c
+++ b/auto-virtserial.c
@@ -93,6 +93,26 @@ static struct host_chars {
}
};
+enum {
+ TEST_OPEN = 0,
+ TEST_CLOSE,
+ TEST_MULTI_OPEN,
+ TEST_SYSFS_UDEV,
+ TEST_READ_WO_HOST,
+ TEST_BLOCKING_READ,
+ TEST_NOBLOCK_READ,
+ TEST_POLL,
+ TEST_G_THROTTLE,
+ TEST_H_THROTTLE,
+ TEST_G_CACHING,
+ TEST_H_CACHING,
+ TEST_FILE_SEND,
+ TEST_CONSOLE,
+ TEST_END
+};
+
+static bool tests[TEST_END];
+
static void handle_guest_error(struct guest_packet *gpkt)
{
char *buf;
@@ -939,13 +959,14 @@ skip_guest:
host_close_chardev(nr);
}
-static int run_test(int (test)(int nr), int nr)
+static int run_test(int (test)(int nr), int nr, int test_nr)
{
- int ret;
-
- ret = (test)(nr);
- post_test_cleanup(nr);
+ int ret = 0;
+ if (tests[test_nr]) {
+ ret = (test)(nr);
+ post_test_cleanup(nr);
+ }
return ret;
}
@@ -959,51 +980,44 @@ static int start_tests(void)
* qemu version.
*/
- test_open(2);
- test_close(2);
- test_multiple_open(2);
+ run_test(test_open, 2, TEST_OPEN);
+ run_test(test_close, 2, TEST_CLOSE);
+ run_test(test_multiple_open, 2, TEST_MULTI_OPEN);
- test_sysfs_and_udev(2);
+ run_test(test_sysfs_and_udev, 2, TEST_SYSFS_UDEV);
- test_read_without_host(2);
+ run_test(test_read_without_host, 2, TEST_READ_WO_HOST);
- test_blocking_read(2);
- test_nonblocking_read(2);
+ run_test(test_blocking_read, 2, TEST_BLOCKING_READ);
+ run_test(test_nonblocking_read, 2, TEST_NOBLOCK_READ);
- test_poll(2);
-
- /*
- * Use run_test when for later tests as poll() and
- * read() calls are used in the post_test_cleanup()
- * routine. We should make sure they work as expected
- * before using them.
- */
+ run_test(test_poll, 2, TEST_POLL);
/* Throttling is not enabled on this port */
- run_test(test_guest_throttle, 2);
+ run_test(test_guest_throttle, 2, TEST_G_THROTTLE);
/* Throttling is enabled on this port */
- run_test(test_guest_throttle, 4);
+ run_test(test_guest_throttle, 4, TEST_G_THROTTLE);
/* Throttling is not enabled on this port */
- run_test(test_host_throttle, 2);
+ run_test(test_host_throttle, 2, TEST_H_THROTTLE);
/* Throttling is enabled on this port */
- run_test(test_host_throttle, 4);
+ run_test(test_host_throttle, 4, TEST_H_THROTTLE);
/* Caching is enabled on this port */
- run_test(test_guest_caching, 2);
+ run_test(test_guest_caching, 2, TEST_G_CACHING);
/* Caching is not enabled on this port */
- run_test(test_guest_caching, 3);
+ run_test(test_guest_caching, 3, TEST_G_CACHING);
/* Caching is enabled on this port */
- run_test(test_host_caching, 2);
+ run_test(test_host_caching, 2, TEST_H_CACHING);
/* Caching is not enabled on this port */
- run_test(test_host_caching, 3);
+ run_test(test_host_caching, 3, TEST_H_CACHING);
/* Sends a big file across, compares sha1sums */
- run_test(test_file_send, 2);
+ run_test(test_file_send, 2, TEST_FILE_SEND);
}
/* The console test should work in any case. */
- run_test(test_console, 0);
+ run_test(test_console, 0, TEST_CONSOLE);
return 0;
}
@@ -1068,6 +1082,10 @@ int main(int argc, const char *argv[])
}
}
next:
+ /* mark all tests as 'to be run' */
+ for (i = 0; i < TEST_END; i++)
+ tests[i] = true;
+
/* Now we're all set to start our tests. */
start_tests();
show_stats();