summaryrefslogtreecommitdiffstats
path: root/tests/test-qht-par.c
blob: d8a83caf5cc05d3f8fa1761dd85346c1d75700f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright (C) 2016, Emilio G. Cota <cota@braap.org>
 *
 * License: GNU GPL, version 2 or later.
 *   See the COPYING file in the top-level directory.
 */
#include "qemu/osdep.h"

#define TEST_QHT_STRING "tests/qht-bench 1>/dev/null 2>&1 -R -S0.1 -D10000 -N1 "

static void test_qht(int n_threads, int update_rate, int duration)
{
    char *str;
    int rc;

    str = g_strdup_printf(TEST_QHT_STRING "-n %d -u %d -d %d",
                          n_threads, update_rate, duration);
    rc = system(str);
    g_free(str);
    g_assert_cmpint(rc, ==, 0);
}

static void test_2th0u1s(void)
{
    test_qht(2, 0, 1);
}

static void test_2th20u1s(void)
{
    test_qht(2, 20, 1);
}

static void test_2th0u5s(void)
{
    test_qht(2, 0, 5);
}

static void test_2th20u5s(void)
{
    test_qht(2, 20, 5);
}

int main(int argc, char *argv[])
{
    g_test_init(&argc, &argv, NULL);

    if (g_test_quick()) {
        g_test_add_func("/qht/parallel/2threads-0%updates-1s", test_2th0u1s);
        g_test_add_func("/qht/parallel/2threads-20%updates-1s", test_2th20u1s);
    } else {
        g_test_add_func("/qht/parallel/2threads-0%updates-5s", test_2th0u5s);
        g_test_add_func("/qht/parallel/2threads-20%updates-5s", test_2th20u5s);
    }
    return g_test_run();
}