xref: /qemu/tests/test-qht-par.c (revision e9abfcb5)
1*896a9ee9SEmilio G. Cota /*
2*896a9ee9SEmilio G. Cota  * Copyright (C) 2016, Emilio G. Cota <cota@braap.org>
3*896a9ee9SEmilio G. Cota  *
4*896a9ee9SEmilio G. Cota  * License: GNU GPL, version 2 or later.
5*896a9ee9SEmilio G. Cota  *   See the COPYING file in the top-level directory.
6*896a9ee9SEmilio G. Cota  */
7*896a9ee9SEmilio G. Cota #include "qemu/osdep.h"
8*896a9ee9SEmilio G. Cota 
9*896a9ee9SEmilio G. Cota #define TEST_QHT_STRING "tests/qht-bench 1>/dev/null 2>&1 -R -S0.1 -D10000 -N1 "
10*896a9ee9SEmilio G. Cota 
test_qht(int n_threads,int update_rate,int duration)11*896a9ee9SEmilio G. Cota static void test_qht(int n_threads, int update_rate, int duration)
12*896a9ee9SEmilio G. Cota {
13*896a9ee9SEmilio G. Cota     char *str;
14*896a9ee9SEmilio G. Cota     int rc;
15*896a9ee9SEmilio G. Cota 
16*896a9ee9SEmilio G. Cota     str = g_strdup_printf(TEST_QHT_STRING "-n %d -u %d -d %d",
17*896a9ee9SEmilio G. Cota                           n_threads, update_rate, duration);
18*896a9ee9SEmilio G. Cota     rc = system(str);
19*896a9ee9SEmilio G. Cota     g_free(str);
20*896a9ee9SEmilio G. Cota     g_assert_cmpint(rc, ==, 0);
21*896a9ee9SEmilio G. Cota }
22*896a9ee9SEmilio G. Cota 
test_2th0u1s(void)23*896a9ee9SEmilio G. Cota static void test_2th0u1s(void)
24*896a9ee9SEmilio G. Cota {
25*896a9ee9SEmilio G. Cota     test_qht(2, 0, 1);
26*896a9ee9SEmilio G. Cota }
27*896a9ee9SEmilio G. Cota 
test_2th20u1s(void)28*896a9ee9SEmilio G. Cota static void test_2th20u1s(void)
29*896a9ee9SEmilio G. Cota {
30*896a9ee9SEmilio G. Cota     test_qht(2, 20, 1);
31*896a9ee9SEmilio G. Cota }
32*896a9ee9SEmilio G. Cota 
test_2th0u5s(void)33*896a9ee9SEmilio G. Cota static void test_2th0u5s(void)
34*896a9ee9SEmilio G. Cota {
35*896a9ee9SEmilio G. Cota     test_qht(2, 0, 5);
36*896a9ee9SEmilio G. Cota }
37*896a9ee9SEmilio G. Cota 
test_2th20u5s(void)38*896a9ee9SEmilio G. Cota static void test_2th20u5s(void)
39*896a9ee9SEmilio G. Cota {
40*896a9ee9SEmilio G. Cota     test_qht(2, 20, 5);
41*896a9ee9SEmilio G. Cota }
42*896a9ee9SEmilio G. Cota 
main(int argc,char * argv[])43*896a9ee9SEmilio G. Cota int main(int argc, char *argv[])
44*896a9ee9SEmilio G. Cota {
45*896a9ee9SEmilio G. Cota     g_test_init(&argc, &argv, NULL);
46*896a9ee9SEmilio G. Cota 
47*896a9ee9SEmilio G. Cota     if (g_test_quick()) {
48*896a9ee9SEmilio G. Cota         g_test_add_func("/qht/parallel/2threads-0%updates-1s", test_2th0u1s);
49*896a9ee9SEmilio G. Cota         g_test_add_func("/qht/parallel/2threads-20%updates-1s", test_2th20u1s);
50*896a9ee9SEmilio G. Cota     } else {
51*896a9ee9SEmilio G. Cota         g_test_add_func("/qht/parallel/2threads-0%updates-5s", test_2th0u5s);
52*896a9ee9SEmilio G. Cota         g_test_add_func("/qht/parallel/2threads-20%updates-5s", test_2th20u5s);
53*896a9ee9SEmilio G. Cota     }
54*896a9ee9SEmilio G. Cota     return g_test_run();
55*896a9ee9SEmilio G. Cota }
56