tests/ucxtest.c

Wed, 27 Dec 2023 14:54:04 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 27 Dec 2023 14:54:04 +0100
changeset 769
b53e0e003d7e
parent 768
0e1cf2cd500e
child 770
ed710122af44
permissions
-rw-r--r--

change default make target from 'compile test-compile' to 'check'

766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2023 Mike Becker, Olaf Wintermann All rights reserved.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 */
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28
767
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
29 #include "cx/test.h"
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
30
d31f4d4075dc migrate utils tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 766
diff changeset
31 CxTestSuite *cx_test_suite_utils(void);
768
0e1cf2cd500e migrate hash_key tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 767
diff changeset
32 CxTestSuite *cx_test_suite_hash_key(void);
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 #define run_tests(suite) cx_test_run_stdout(suite); success += (suite)->success; failure += (suite)->failure
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36 int main(void) {
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 printf("UCX Tests\n---------\n");
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 unsigned success = 0, failure = 0;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 // create test suites
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 CxTestSuite
768
0e1cf2cd500e migrate hash_key tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 767
diff changeset
43 *utils = cx_test_suite_utils(),
0e1cf2cd500e migrate hash_key tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 767
diff changeset
44 *hash_key = cx_test_suite_hash_key();
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 // run tests
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 run_tests(utils);
768
0e1cf2cd500e migrate hash_key tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 767
diff changeset
48 run_tests(hash_key);
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 // print overall result
768
0e1cf2cd500e migrate hash_key tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 767
diff changeset
51 printf("=== OVERALL RESULT ===\n");
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52 printf(" Total: %u\n Success: %u\n Failure: %u\n",
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 success + failure, success, failure);
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 cx_test_suite_free(utils);
768
0e1cf2cd500e migrate hash_key tests - relates to #342
Mike Becker <universe@uap-core.de>
parents: 767
diff changeset
56 cx_test_suite_free(hash_key);
766
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58 return failure > 0 ? 1 : 0;
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 }
e59b76889f00 bring back UCX test - fixes #341
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60

mercurial