author | Markus Kauppila <markus.kauppila@gmail.com> |
Sun, 28 Aug 2011 20:27:25 +0300 | |
changeset 5844 | fa860270f65c |
parent 5843 | 66dc563da07e |
child 5845 | 02eace7c44a5 |
permissions | -rw-r--r-- |
5659
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
1 |
/* |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
2 |
Copyright (C) 2011 Markus Kauppila <markus.kauppila@gmail.com> |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
3 |
|
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
4 |
This software is provided 'as-is', without any express or implied |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
5 |
warranty. In no event will the authors be held liable for any damages |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
6 |
arising from the use of this software. |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
7 |
|
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
8 |
Permission is granted to anyone to use this software for any purpose, |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
9 |
including commercial applications, and to alter it and redistribute it |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
10 |
freely, subject to the following restrictions: |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
11 |
|
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
12 |
1. The origin of this software must not be misrepresented; you must not |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
13 |
claim that you wrote the original software. If you use this software |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
14 |
in a product, an acknowledgment in the product documentation would be |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
15 |
appreciated but is not required. |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
16 |
2. Altered source versions must be plainly marked as such, and must not be |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
17 |
misrepresented as being the original software. |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
18 |
3. This notice may not be removed or altered from any source distribution. |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
19 |
*/ |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
20 |
|
5662
57fc58008d76
Tiny changes to runner
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5659
diff
changeset
|
21 |
#include "SDL/SDL.h" |
5659
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
22 |
|
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
23 |
#include <stdio.h> |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
24 |
#include <stdlib.h> |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
25 |
#include <unistd.h> |
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
26 |
#include <string.h> |
5689
f1ab815aa4af
Initial version of "scan tests/ for test suites" functionality.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5687
diff
changeset
|
27 |
#include <dirent.h> |
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
28 |
|
5659
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
29 |
#include <sys/types.h> |
5787
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
30 |
#include <sys/stat.h> |
5659
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
31 |
|
5804
d82711e39c05
Reorganizing the project.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5797
diff
changeset
|
32 |
#include "../../include/SDL_test.h" |
d82711e39c05
Reorganizing the project.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5797
diff
changeset
|
33 |
#include "../../config.h" |
5742
443d356b5af8
Added command option --version
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5741
diff
changeset
|
34 |
|
5811
36707a804e66
Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5809
diff
changeset
|
35 |
#include "../libSDLtest/fuzzer/fuzzer.h" |
5746
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
36 |
|
5811
36707a804e66
Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5809
diff
changeset
|
37 |
#include "../libSDLtest/plain_logger.h" |
36707a804e66
Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5809
diff
changeset
|
38 |
#include "../libSDLtest/xml_logger.h" |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
39 |
#include "../libSDLtest/logger_helpers.h" |
5804
d82711e39c05
Reorganizing the project.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5797
diff
changeset
|
40 |
|
5713
08edd9b3ec32
Logging system added to harness. Logging system doesn't
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5700
diff
changeset
|
41 |
#include "logger.h" |
5772
a6c404e897af
Testing out implementation for skipping unsupported test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5770
diff
changeset
|
42 |
#include "support.h" |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
43 |
|
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
44 |
//!< Function pointer to a test case function |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
45 |
typedef void (*TestCaseFp)(void *arg); |
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
46 |
//!< Function pointer to a test case init function |
5797
4936c840d128
Fixing execution key generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5796
diff
changeset
|
47 |
typedef void (*InitTestInvironmentFp)(Uint64); |
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
48 |
//!< Function pointer to a test case quit function |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
49 |
typedef int (*QuitTestInvironmentFp)(void); |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
50 |
//!< Function pointer to a test case set up function |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
51 |
typedef void (*TestCaseSetUpFp)(void *arg); |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
52 |
//!< Function pointer to a test case tear down function |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
53 |
typedef void (*TestCaseTearDownFp)(void *arg); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
54 |
//!< Function pointer to a function which returns the failed assert count |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
55 |
typedef int (*CountFailedAssertsFp)(void); |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
56 |
|
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
57 |
|
5676
02a0f7889834
Refactoring runner.c. Added --help/-h command line option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5675
diff
changeset
|
58 |
//!< Flag for executing tests in-process |
02a0f7889834
Refactoring runner.c. Added --help/-h command line option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5675
diff
changeset
|
59 |
static int execute_inproc = 0; |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
60 |
|
5700
5644a467ec5f
Added new command line option: --show-tests
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5697
diff
changeset
|
61 |
//!< Flag for only printing out the test names |
5644a467ec5f
Added new command line option: --show-tests
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5697
diff
changeset
|
62 |
static int only_print_tests = 0; |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
63 |
|
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
64 |
//!< Flag for executing only test with selected name |
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
65 |
static int only_selected_test = 0; |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
66 |
|
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
67 |
//!< Flag for executing only the selected test suite |
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
68 |
static int only_selected_suite = 0; |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
69 |
|
5693
cd0110de8ad5
Added test and suite names to the output.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5692
diff
changeset
|
70 |
//!< Flag for executing only tests that contain certain string in their name |
cd0110de8ad5
Added test and suite names to the output.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5692
diff
changeset
|
71 |
static int only_tests_with_string = 0; |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
72 |
|
5713
08edd9b3ec32
Logging system added to harness. Logging system doesn't
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5700
diff
changeset
|
73 |
//!< Flag for enabling XML logging |
08edd9b3ec32
Logging system added to harness. Logging system doesn't
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5700
diff
changeset
|
74 |
static int xml_enabled = 0; |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
75 |
|
5728
7cf47cdaf4ab
Added user-supplied XSL style sheets for XML-based test reports.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5727
diff
changeset
|
76 |
//! Flag for enabling user-supplied style sheet for XML test report |
7cf47cdaf4ab
Added user-supplied XSL style sheets for XML-based test reports.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5727
diff
changeset
|
77 |
static int custom_xsl_enabled = 0; |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
78 |
|
5731
507fffef86ad
Redefined the usage of --xsl command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5730
diff
changeset
|
79 |
//! Flag for disabling xsl-style from xml report |
507fffef86ad
Redefined the usage of --xsl command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5730
diff
changeset
|
80 |
static int xsl_enabled = 0; |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
81 |
|
5769
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
82 |
//! Flag for enabling universal timeout for tests |
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
83 |
static int universal_timeout_enabled = 0; |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
84 |
|
5785
7fc252ce5d1d
Added simple logging levels to logging system.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5784
diff
changeset
|
85 |
//! Flag for enabling verbose logging |
7fc252ce5d1d
Added simple logging levels to logging system.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5784
diff
changeset
|
86 |
static int enable_verbose_logger = 0; |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
87 |
|
5786
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
88 |
//! Flag for using user supplied run seed |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
89 |
static int userRunSeed = 0; |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
90 |
|
5788
eeb5431a8cbf
Made run seed more file name friendly.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5787
diff
changeset
|
91 |
//! Whether or not logger should log to stdout instead of file |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
92 |
static int log_stdout_enabled = 1; |
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
93 |
|
5827
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
94 |
//! Whether or not dummy suite should be included to the test run |
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
95 |
static int include_dummy_suite = 0; |
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
96 |
|
5691
c0b4bcd901a0
Removed unnecessary function.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5690
diff
changeset
|
97 |
//!< Size of the test and suite name buffers |
5689
f1ab815aa4af
Initial version of "scan tests/ for test suites" functionality.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5687
diff
changeset
|
98 |
#define NAME_BUFFER_SIZE 1024 |
5787
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
99 |
|
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
100 |
//!< Name of the selected test |
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
101 |
char selected_test_name[NAME_BUFFER_SIZE]; |
5787
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
102 |
|
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
103 |
//!< Name of the selected suite |
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
104 |
char selected_suite_name[NAME_BUFFER_SIZE]; |
5681
7abfcc71aa7d
Runner can execute multiple test suites consecutively.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5680
diff
changeset
|
105 |
|
5693
cd0110de8ad5
Added test and suite names to the output.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5692
diff
changeset
|
106 |
//!< substring of test case name |
cd0110de8ad5
Added test and suite names to the output.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5692
diff
changeset
|
107 |
char testcase_name_substring[NAME_BUFFER_SIZE]; |
cd0110de8ad5
Added test and suite names to the output.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5692
diff
changeset
|
108 |
|
5728
7cf47cdaf4ab
Added user-supplied XSL style sheets for XML-based test reports.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5727
diff
changeset
|
109 |
//! Name for user-supplied XSL style sheet name |
7cf47cdaf4ab
Added user-supplied XSL style sheets for XML-based test reports.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5727
diff
changeset
|
110 |
char xsl_stylesheet_name[NAME_BUFFER_SIZE]; |
5794
e39e9c62c671
Fixed harness seed generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5793
diff
changeset
|
111 |
|
5780
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
112 |
//! User-suppled timeout value for tests |
5769
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
113 |
int universal_timeout = -1; |
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
114 |
|
5691
c0b4bcd901a0
Removed unnecessary function.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5690
diff
changeset
|
115 |
//! Default directory of the test suites |
c0b4bcd901a0
Removed unnecessary function.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5690
diff
changeset
|
116 |
#define DEFAULT_TEST_DIRECTORY "tests/" |
c0b4bcd901a0
Removed unnecessary function.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5690
diff
changeset
|
117 |
|
5787
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
118 |
//! Default directory for placing log files |
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
119 |
#define DEFAULT_LOG_DIRECTORY "logs" |
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
120 |
|
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
121 |
//! Default directory of the test suites |
5842
2ea6b78e504f
Changed logging behavior. Runner uses stdout as default and
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5835
diff
changeset
|
122 |
#define DEFAULT_LOG_FILENAME "testrun" |
5787
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
123 |
|
5795
134c0f7ae826
Changed SetUpLogger based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5794
diff
changeset
|
124 |
//! Defines directory separator |
134c0f7ae826
Changed SetUpLogger based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5794
diff
changeset
|
125 |
#define DIRECTORY_SEPARATOR '/' |
134c0f7ae826
Changed SetUpLogger based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5794
diff
changeset
|
126 |
|
5827
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
127 |
#define DUMMY_TEST_NAME "libtestdummy" |
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
128 |
|
5795
134c0f7ae826
Changed SetUpLogger based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5794
diff
changeset
|
129 |
//! Name of the default stylesheet |
134c0f7ae826
Changed SetUpLogger based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5794
diff
changeset
|
130 |
const char *defaultXSLStylesheet = "style.xsl"; |
134c0f7ae826
Changed SetUpLogger based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5794
diff
changeset
|
131 |
|
5786
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
132 |
//! Fuzzer seed for the harness |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
133 |
char *runSeed = NULL; |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
134 |
|
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
135 |
//! Execution key that user supplied via command options |
5797
4936c840d128
Fixing execution key generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5796
diff
changeset
|
136 |
Uint64 userExecKey = 0; |
5780
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
137 |
|
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
138 |
//! How man time a test will be invocated |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
139 |
int testInvocationCount = 1; |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
140 |
|
5787
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
141 |
//! Stores the basename for log files |
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
142 |
char log_basename[NAME_BUFFER_SIZE]; |
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
143 |
|
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
144 |
//! Stores directory name for placing the logs |
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
145 |
char log_directory[NAME_BUFFER_SIZE]; |
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
146 |
|
5786
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
147 |
// \todo add comments |
5780
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
148 |
int totalTestFailureCount = 0, totalTestPassCount = 0, totalTestSkipCount = 0; |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
149 |
int testFailureCount = 0, testPassCount = 0, testSkipCount = 0; |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
150 |
|
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
151 |
|
5689
f1ab815aa4af
Initial version of "scan tests/ for test suites" functionality.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5687
diff
changeset
|
152 |
/*! |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
153 |
* Holds information about test suite such as it's name |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
154 |
* and pointer to dynamic library. Implemented as linked list. |
5689
f1ab815aa4af
Initial version of "scan tests/ for test suites" functionality.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5687
diff
changeset
|
155 |
*/ |
f1ab815aa4af
Initial version of "scan tests/ for test suites" functionality.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5687
diff
changeset
|
156 |
typedef struct TestSuiteReference { |
5692
249e54c47b90
Creating pipeline for test case selection. Work in progress.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5691
diff
changeset
|
157 |
char *name; //!< test suite name |
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
158 |
char *directoryPath; //!< test suites path (eg. tests/libtestsuite) |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
159 |
void *library; //!< pointer to shared/dynamic library implementing the suite |
5692
249e54c47b90
Creating pipeline for test case selection. Work in progress.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5691
diff
changeset
|
160 |
|
5689
f1ab815aa4af
Initial version of "scan tests/ for test suites" functionality.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5687
diff
changeset
|
161 |
struct TestSuiteReference *next; //!< Pointer to next item in the list |
f1ab815aa4af
Initial version of "scan tests/ for test suites" functionality.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5687
diff
changeset
|
162 |
} TestSuiteReference; |
f1ab815aa4af
Initial version of "scan tests/ for test suites" functionality.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5687
diff
changeset
|
163 |
|
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
164 |
|
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
165 |
/*! |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
166 |
* Holds information about the tests that will be executed. |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
167 |
* |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
168 |
* Implemented as linked list. |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
169 |
*/ |
5692
249e54c47b90
Creating pipeline for test case selection. Work in progress.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5691
diff
changeset
|
170 |
typedef struct TestCaseItem { |
249e54c47b90
Creating pipeline for test case selection. Work in progress.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5691
diff
changeset
|
171 |
char *testName; |
249e54c47b90
Creating pipeline for test case selection. Work in progress.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5691
diff
changeset
|
172 |
char *suiteName; |
249e54c47b90
Creating pipeline for test case selection. Work in progress.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5691
diff
changeset
|
173 |
|
5713
08edd9b3ec32
Logging system added to harness. Logging system doesn't
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5700
diff
changeset
|
174 |
char *description; |
08edd9b3ec32
Logging system added to harness. Logging system doesn't
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5700
diff
changeset
|
175 |
long requirements; |
08edd9b3ec32
Logging system added to harness. Logging system doesn't
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5700
diff
changeset
|
176 |
long timeout; |
08edd9b3ec32
Logging system added to harness. Logging system doesn't
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5700
diff
changeset
|
177 |
|
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
178 |
InitTestInvironmentFp initTestEnvironment; |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
179 |
TestCaseSetUpFp testSetUp; |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
180 |
TestCaseFp testCase; |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
181 |
TestCaseTearDownFp testTearDown; |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
182 |
QuitTestInvironmentFp quitTestEnvironment; |
5692
249e54c47b90
Creating pipeline for test case selection. Work in progress.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5691
diff
changeset
|
183 |
|
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
184 |
CountFailedAssertsFp countFailedAsserts; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
185 |
|
5692
249e54c47b90
Creating pipeline for test case selection. Work in progress.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5691
diff
changeset
|
186 |
struct TestCaseItem *next; |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
187 |
} TestCase; |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
188 |
|
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
189 |
|
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
190 |
/*! Some function prototypes. Add the rest of functions and move to runner.h */ |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
191 |
TestCaseFp LoadTestCaseFunction(void *suite, char *testName); |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
192 |
InitTestInvironmentFp LoadInitTestInvironmentFunction(void *suite); |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
193 |
QuitTestInvironmentFp LoadQuitTestInvironmentFunction(void *suite); |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
194 |
TestCaseReference **QueryTestCaseReferences(void *library); |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
195 |
TestCaseSetUpFp LoadTestSetUpFunction(void *suite); |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
196 |
TestCaseTearDownFp LoadTestTearDownFunction(void *suite); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
197 |
CountFailedAssertsFp LoadCountFailedAssertsFunction(void *suite); |
5769
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
198 |
void KillHungTestInChildProcess(int signum); |
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
199 |
void UnloadTestSuites(TestSuiteReference *suites); |
5809
adc13772de72
Fixed a bunch of compiler warnings.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5808
diff
changeset
|
200 |
int FilterTestCase(TestCaseReference *testReference); |
adc13772de72
Fixed a bunch of compiler warnings.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5808
diff
changeset
|
201 |
int HandleChildProcessReturnValue(int stat_lock); |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
202 |
|
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
203 |
|
5746
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
204 |
/*! Pointers to selected logger implementation */ |
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
205 |
RunStartedFp RunStarted = NULL; |
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
206 |
RunEndedFp RunEnded = NULL; |
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
207 |
SuiteStartedFp SuiteStarted = NULL; |
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
208 |
SuiteEndedFp SuiteEnded = NULL; |
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
209 |
TestStartedFp TestStarted = NULL; |
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
210 |
TestEndedFp TestEnded = NULL; |
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
211 |
AssertFp Assert = NULL; |
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
212 |
AssertWithValuesFp AssertWithValues = NULL; |
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
213 |
AssertSummaryFp AssertSummary = NULL; |
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
214 |
LogFp Log = NULL; |
b7a0b33b08f4
Fixed the interface between tests suites and logger.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5742
diff
changeset
|
215 |
|
5681
7abfcc71aa7d
Runner can execute multiple test suites consecutively.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5680
diff
changeset
|
216 |
|
5671
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
217 |
/*! |
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
218 |
* Scans the tests/ directory and returns the names |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
219 |
* of the dynamic libraries implementing the test suites. |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
220 |
* |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
221 |
* Note: currently function assumes that test suites names |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
222 |
* are in following format: libtestsuite.dylib or libtestsuite.so. |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
223 |
* |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
224 |
* Note: if only_selected_suite flags is non-zero, only the selected |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
225 |
* test will be loaded. |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
226 |
* |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
227 |
* \param directoryName Name of the directory which will be scanned |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
228 |
* \param extension What file extension is used with dynamic objects |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
229 |
* |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
230 |
* \return Pointer to TestSuiteReference which holds all the info about suites |
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
231 |
* or NULL on failure |
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
232 |
*/ |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
233 |
TestSuiteReference * |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
234 |
ScanForTestSuites(char *directoryName, char *extension) |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
235 |
{ |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
236 |
typedef struct dirent Entry; |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
237 |
TestSuiteReference *suites = NULL; |
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
238 |
TestSuiteReference *reference = NULL; |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
239 |
Entry *entry = NULL; |
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
240 |
DIR *directory = NULL; |
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
241 |
|
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
242 |
if(directoryName == NULL || extension == NULL || |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
243 |
SDL_strlen(directoryName) == 0 || SDL_strlen(extension) == 0) { |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
244 |
return NULL; |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
245 |
} |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
246 |
|
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
247 |
directory = opendir(directoryName); |
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
248 |
if(!directory) { |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
249 |
fprintf(stderr, "Failed to open test suite directory: %s\n", directoryName); |
5804
d82711e39c05
Reorganizing the project.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5797
diff
changeset
|
250 |
perror("Error message"); |
5792
ec908de81ba5
Fixed problem in ScanForTestSuites concerning hidden
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5791
diff
changeset
|
251 |
exit(2); |
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
252 |
} |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
253 |
|
5809
adc13772de72
Fixed a bunch of compiler warnings.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5808
diff
changeset
|
254 |
while( (entry = readdir(directory)) ) { |
5808
34114b48f322
Fixed 'make distclean'
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5805
diff
changeset
|
255 |
// discards . and .. and hidden files starting with dot and directories etc. |
5805
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
256 |
if(strlen(entry->d_name) > 2 && entry->d_name[0] != '.' && entry->d_type == DT_REG) { |
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
257 |
const char *delimiters = "."; |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
258 |
char *name = strtok(entry->d_name, delimiters); |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
259 |
char *ext = strtok(NULL, delimiters); |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
260 |
|
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
261 |
if(name == NULL || ext == NULL) { |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
262 |
goto error; |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
263 |
} |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
264 |
|
5827
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
265 |
|
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
266 |
int ok = 1; // on default, we want to include all tests |
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
267 |
|
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
268 |
// filter out all other suites but the selected test suite |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
269 |
if(only_selected_suite) { |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
270 |
ok = SDL_strncmp(selected_suite_name, name, NAME_BUFFER_SIZE) == 0; |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
271 |
} |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
272 |
|
5827
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
273 |
if(SDL_strncmp(name, DUMMY_TEST_NAME, NAME_BUFFER_SIZE) == 0) { |
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
274 |
if(include_dummy_suite) { |
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
275 |
ok = 1; |
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
276 |
} else { |
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
277 |
ok = 0; |
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
278 |
} |
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
279 |
} |
ef0942587b80
Added --include-dummy option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5826
diff
changeset
|
280 |
|
5792
ec908de81ba5
Fixed problem in ScanForTestSuites concerning hidden
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5791
diff
changeset
|
281 |
if(ok && SDL_strncmp(ext, extension, SDL_strlen(extension)) == 0) { |
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
282 |
// create test suite reference |
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
283 |
reference = (TestSuiteReference *) SDL_malloc(sizeof(TestSuiteReference)); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
284 |
if(reference == NULL) { |
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
285 |
goto error; |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
286 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
287 |
|
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
288 |
memset(reference, 0, sizeof(TestSuiteReference)); |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
289 |
|
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
290 |
const Uint32 dirSize = SDL_strlen(directoryName); |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
291 |
const Uint32 extSize = SDL_strlen(ext); |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
292 |
const Uint32 nameSize = SDL_strlen(name) + 1; |
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
293 |
|
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
294 |
// copy the name |
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
295 |
reference->name = SDL_malloc(nameSize * sizeof(char)); |
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
296 |
if(reference->name == NULL) { |
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
297 |
goto error; |
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
298 |
} |
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
299 |
|
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
300 |
SDL_snprintf(reference->name, nameSize, "%s", name); |
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
301 |
|
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
302 |
// copy the directory path |
5795
134c0f7ae826
Changed SetUpLogger based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5794
diff
changeset
|
303 |
const Uint32 dpSize = dirSize + nameSize + 1 + extSize + 1; |
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
304 |
reference->directoryPath = SDL_malloc(dpSize * sizeof(char)); |
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
305 |
if(reference->directoryPath == NULL) { |
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
306 |
goto error; |
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
307 |
} |
5791
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
308 |
|
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
309 |
SDL_snprintf(reference->directoryPath, dpSize, "%s%s.%s", |
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
310 |
directoryName, name, ext); |
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
311 |
|
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
312 |
reference->next = suites; |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
313 |
suites = reference; |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
314 |
} |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
315 |
} |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
316 |
} |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
317 |
|
5796
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
318 |
goto finished; |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
319 |
|
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
320 |
error: |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
321 |
if(reference) { |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
322 |
SDL_free(reference->name); |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
323 |
SDL_free(reference->directoryPath); |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
324 |
SDL_free(reference); |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
325 |
} |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
326 |
|
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
327 |
// Unload all the suites that are loaded thus far |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
328 |
UnloadTestSuites(suites); |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
329 |
suites = NULL; |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
330 |
|
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
331 |
finished: |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
332 |
if(directory) { |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
333 |
closedir(directory); |
610df1cc7b4a
Fixed ScanForTestSuites function based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5795
diff
changeset
|
334 |
} |
5729
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
335 |
|
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
336 |
return suites; |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
337 |
} |
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
338 |
|
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
339 |
|
27be98c43bbc
Removed directory from test suite names.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5728
diff
changeset
|
340 |
/*! |
5676
02a0f7889834
Refactoring runner.c. Added --help/-h command line option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5675
diff
changeset
|
341 |
* Loads test suite which is implemented as dynamic library. |
02a0f7889834
Refactoring runner.c. Added --help/-h command line option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5675
diff
changeset
|
342 |
* |
5733
9c9eeded847a
Fixed doxygen markup error.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5731
diff
changeset
|
343 |
* \param suite Reference to test suite that'll be loaded |
5676
02a0f7889834
Refactoring runner.c. Added --help/-h command line option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5675
diff
changeset
|
344 |
* |
02a0f7889834
Refactoring runner.c. Added --help/-h command line option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5675
diff
changeset
|
345 |
* \return Pointer to loaded test suite, or NULL if library could not be loaded |
02a0f7889834
Refactoring runner.c. Added --help/-h command line option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5675
diff
changeset
|
346 |
*/ |
02a0f7889834
Refactoring runner.c. Added --help/-h command line option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5675
diff
changeset
|
347 |
void * |
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
348 |
LoadTestSuite(const TestSuiteReference *suite) |
5676
02a0f7889834
Refactoring runner.c. Added --help/-h command line option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5675
diff
changeset
|
349 |
{ |
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
350 |
void *library = SDL_LoadObject(suite->directoryPath); |
5659
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
351 |
if(library == NULL) { |
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
352 |
fprintf(stderr, "Loading %s failed\n", suite->name); |
5675
8513baf78c95
Fixes to doxygen comments.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5674
diff
changeset
|
353 |
fprintf(stderr, "%s\n", SDL_GetError()); |
5659
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
354 |
} |
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
355 |
|
5667
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
356 |
return library; |
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
357 |
} |
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
358 |
|
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
359 |
|
5671
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
360 |
/*! |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
361 |
* Goes through all the given TestSuiteReferences |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
362 |
* and loads the dynamic libraries. Updates the suites |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
363 |
* parameter on-the-fly and returns it. |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
364 |
* |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
365 |
* \param suites Suites that will be loaded |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
366 |
* |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
367 |
* \return Updated TestSuiteReferences with pointer to loaded libraries |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
368 |
*/ |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
369 |
TestSuiteReference * |
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
370 |
LoadTestSuites(TestSuiteReference *suites) |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
371 |
{ |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
372 |
TestSuiteReference *reference = NULL; |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
373 |
for(reference = suites; reference; reference = reference->next) { |
5730
5c094958a62f
Separated test suite name from its directory path. Fixes
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5729
diff
changeset
|
374 |
reference->library = LoadTestSuite(reference); |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
375 |
} |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
376 |
|
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
377 |
return suites; |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
378 |
} |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
379 |
|
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
380 |
|
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
381 |
/*! |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
382 |
* Unloads the given TestSuiteReferences. Frees all |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
383 |
* the allocated resources including the dynamic libraries. |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
384 |
* |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
385 |
* \param suites TestSuiteReferences for deallocation process |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
386 |
*/ |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
387 |
void |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
388 |
UnloadTestSuites(TestSuiteReference *suites) |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
389 |
{ |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
390 |
TestSuiteReference *ref = suites; |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
391 |
while(ref) { |
5805
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
392 |
if(ref->name) |
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
393 |
SDL_free(ref->name); |
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
394 |
|
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
395 |
if(ref->directoryPath) |
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
396 |
SDL_free(ref->directoryPath); |
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
397 |
|
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
398 |
if(ref->library) |
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
399 |
SDL_UnloadObject(ref->library); |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
400 |
|
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
401 |
TestSuiteReference *temp = ref->next; |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
402 |
SDL_free(ref); |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
403 |
ref = temp; |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
404 |
} |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
405 |
|
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
406 |
suites = NULL; |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
407 |
} |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
408 |
|
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
409 |
|
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
410 |
/*! |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
411 |
* Goes through the previously loaded test suites and |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
412 |
* loads test cases from them. Test cases are filtered |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
413 |
* during the process. Function will only return the |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
414 |
* test cases which aren't filtered out. |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
415 |
* |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
416 |
* \param suites previously loaded test suites |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
417 |
* |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
418 |
* \return Test cases that survived filtering process. |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
419 |
*/ |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
420 |
TestCase * |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
421 |
LoadTestCases(TestSuiteReference *suites) |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
422 |
{ |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
423 |
TestCase *testCases = NULL; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
424 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
425 |
TestSuiteReference *suiteReference = NULL; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
426 |
for(suiteReference = suites; suiteReference; suiteReference = suiteReference->next) { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
427 |
TestCaseReference **tests = QueryTestCaseReferences(suiteReference->library); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
428 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
429 |
TestCaseReference *testReference = NULL; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
430 |
int counter = 0; |
5792
ec908de81ba5
Fixed problem in ScanForTestSuites concerning hidden
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5791
diff
changeset
|
431 |
for(testReference = tests[counter]; testReference; testReference = tests[++counter]) { |
ec908de81ba5
Fixed problem in ScanForTestSuites concerning hidden
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5791
diff
changeset
|
432 |
//void *suite = suiteReference->library; |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
433 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
434 |
// Load test case functions |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
435 |
InitTestInvironmentFp initTestEnvironment = LoadInitTestInvironmentFunction(suiteReference->library); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
436 |
QuitTestInvironmentFp quitTestEnvironment = LoadQuitTestInvironmentFunction(suiteReference->library); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
437 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
438 |
TestCaseSetUpFp testSetUp = LoadTestSetUpFunction(suiteReference->library); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
439 |
TestCaseTearDownFp testTearDown = LoadTestTearDownFunction(suiteReference->library); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
440 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
441 |
TestCaseFp testCase = LoadTestCaseFunction(suiteReference->library, testReference->name); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
442 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
443 |
CountFailedAssertsFp countFailedAsserts = LoadCountFailedAssertsFunction(suiteReference->library); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
444 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
445 |
// Do the filtering |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
446 |
if(FilterTestCase(testReference)) { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
447 |
TestCase *item = SDL_malloc(sizeof(TestCase)); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
448 |
memset(item, 0, sizeof(TestCase)); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
449 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
450 |
item->initTestEnvironment = initTestEnvironment; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
451 |
item->quitTestEnvironment = quitTestEnvironment; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
452 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
453 |
item->testSetUp = testSetUp; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
454 |
item->testTearDown = testTearDown; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
455 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
456 |
item->testCase = testCase; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
457 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
458 |
item->countFailedAsserts = countFailedAsserts; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
459 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
460 |
// copy suite name |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
461 |
int length = SDL_strlen(suiteReference->name) + 1; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
462 |
item->suiteName = SDL_malloc(length); |
5791
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
463 |
if(item->suiteName == NULL) { |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
464 |
SDL_free(item); |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
465 |
return NULL; |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
466 |
} |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
467 |
strncpy(item->suiteName, suiteReference->name, length); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
468 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
469 |
// copy test name |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
470 |
length = SDL_strlen(testReference->name) + 1; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
471 |
item->testName = SDL_malloc(length); |
5791
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
472 |
if(item->testName == NULL) { |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
473 |
SDL_free(item->suiteName); |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
474 |
SDL_free(item); |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
475 |
return NULL; |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
476 |
} |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
477 |
strncpy(item->testName, testReference->name, length); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
478 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
479 |
// copy test description |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
480 |
length = SDL_strlen(testReference->description) + 1; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
481 |
item->description = SDL_malloc(length); |
5791
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
482 |
if(item->description == NULL) { |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
483 |
SDL_free(item->description); |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
484 |
SDL_free(item->suiteName); |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
485 |
SDL_free(item); |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
486 |
return NULL; |
a4e354dfcbfa
Fixed potential memory leak from test case loading.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5790
diff
changeset
|
487 |
} |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
488 |
strncpy(item->description, testReference->description, length); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
489 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
490 |
item->requirements = testReference->requirements; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
491 |
item->timeout = testReference->timeout; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
492 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
493 |
// prepend the list |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
494 |
item->next = testCases; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
495 |
testCases = item; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
496 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
497 |
//printf("Added test: %s\n", testReference->name); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
498 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
499 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
500 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
501 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
502 |
return testCases; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
503 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
504 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
505 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
506 |
/*! |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
507 |
* Unloads the given TestCases. Frees all the resources |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
508 |
* allocated for test cases. |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
509 |
* |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
510 |
* \param testCases Test cases to be deallocated |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
511 |
*/ |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
512 |
void |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
513 |
UnloadTestCases(TestCase *testCases) |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
514 |
{ |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
515 |
TestCase *ref = testCases; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
516 |
while(ref) { |
5805
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
517 |
if(ref->testName) |
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
518 |
SDL_free(ref->testName); |
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
519 |
|
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
520 |
if(ref->suiteName) |
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
521 |
SDL_free(ref->suiteName); |
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
522 |
|
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
523 |
if(ref->description) |
df2097bab7ee
Runner is automatically installed to .
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5804
diff
changeset
|
524 |
SDL_free(ref->description); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
525 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
526 |
TestCase *temp = ref->next; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
527 |
SDL_free(ref); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
528 |
ref = temp; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
529 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
530 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
531 |
testCases = NULL; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
532 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
533 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
534 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
535 |
/*! |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
536 |
* Filters a test case based on its properties in TestCaseReference and user |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
537 |
* preference. |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
538 |
* |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
539 |
* \return Non-zero means test will be added to execution list, zero means opposite |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
540 |
*/ |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
541 |
int |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
542 |
FilterTestCase(TestCaseReference *testReference) |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
543 |
{ |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
544 |
int retVal = 1; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
545 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
546 |
if(testReference->enabled == TEST_DISABLED) { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
547 |
retVal = 0; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
548 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
549 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
550 |
if(only_selected_test) { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
551 |
if(SDL_strncmp(testReference->name, selected_test_name, NAME_BUFFER_SIZE) == 0) { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
552 |
retVal = 1; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
553 |
} else { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
554 |
retVal = 0; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
555 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
556 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
557 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
558 |
if(only_tests_with_string) { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
559 |
if(strstr(testReference->name, testcase_name_substring) != NULL) { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
560 |
retVal = 1; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
561 |
} else { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
562 |
retVal = 0; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
563 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
564 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
565 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
566 |
return retVal; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
567 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
568 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
569 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
570 |
/*! |
5671
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
571 |
* Loads the test case references from the given test suite. |
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
572 |
|
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
573 |
* \param library Previously loaded dynamic library AKA test suite |
5675
8513baf78c95
Fixes to doxygen comments.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5674
diff
changeset
|
574 |
* \return Pointer to array of TestCaseReferences or NULL if function failed |
5671
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
575 |
*/ |
5673
07b920bcff70
Fixed doxygen warnings
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5672
diff
changeset
|
576 |
TestCaseReference ** |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
577 |
QueryTestCaseReferences(void *library) |
5673
07b920bcff70
Fixed doxygen warnings
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5672
diff
changeset
|
578 |
{ |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
579 |
TestCaseReference **(*suite)(void); |
5667
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
580 |
|
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
581 |
suite = (TestCaseReference **(*)(void)) SDL_LoadFunction(library, "QueryTestSuite"); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
582 |
if(suite == NULL) { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
583 |
fprintf(stderr, "Loading QueryTestCaseReferences() failed.\n"); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
584 |
fprintf(stderr, "%s\n", SDL_GetError()); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
585 |
} |
5659
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
586 |
|
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
587 |
TestCaseReference **tests = suite(); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
588 |
if(tests == NULL) { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
589 |
fprintf(stderr, "Failed to load test references.\n"); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
590 |
fprintf(stderr, "%s\n", SDL_GetError()); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
591 |
} |
5667
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
592 |
|
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
593 |
return tests; |
5667
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
594 |
} |
5662
57fc58008d76
Tiny changes to runner
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5659
diff
changeset
|
595 |
|
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
596 |
|
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
597 |
/*! |
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
598 |
* Loads test case from a test suite |
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
599 |
* |
5673
07b920bcff70
Fixed doxygen warnings
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5672
diff
changeset
|
600 |
* \param suite a test suite |
07b920bcff70
Fixed doxygen warnings
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5672
diff
changeset
|
601 |
* \param testName Name of the test that is going to be loaded |
5671
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
602 |
* |
5675
8513baf78c95
Fixes to doxygen comments.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5674
diff
changeset
|
603 |
* \return Function Pointer (TestCase) to loaded test case, NULL if function failed |
5671
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
604 |
*/ |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
605 |
TestCaseFp |
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
606 |
LoadTestCaseFunction(void *suite, char *testName) |
5673
07b920bcff70
Fixed doxygen warnings
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5672
diff
changeset
|
607 |
{ |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
608 |
TestCaseFp test = (TestCaseFp) SDL_LoadFunction(suite, testName); |
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
609 |
if(test == NULL) { |
5675
8513baf78c95
Fixes to doxygen comments.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5674
diff
changeset
|
610 |
fprintf(stderr, "Loading test failed, tests == NULL\n"); |
8513baf78c95
Fixes to doxygen comments.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5674
diff
changeset
|
611 |
fprintf(stderr, "%s\n", SDL_GetError()); |
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
612 |
} |
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
613 |
|
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
614 |
return test; |
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
615 |
} |
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
616 |
|
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
617 |
|
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
618 |
/*! |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
619 |
* Loads function that sets up a fixture for a test case. Note: if there's |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
620 |
* no SetUp function present in the suite the function will return NULL. |
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
621 |
* |
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
622 |
* \param suite Used test suite |
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
623 |
* |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
624 |
* \return Function pointer to test case's set up function |
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
625 |
*/ |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
626 |
TestCaseSetUpFp |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
627 |
LoadTestSetUpFunction(void *suite) { |
5764
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
628 |
return (TestCaseSetUpFp) SDL_LoadFunction(suite, "SetUp"); |
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
629 |
} |
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
630 |
|
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
631 |
|
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
632 |
/*! |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
633 |
* Loads function that tears down a fixture for a test case. Note: if there's |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
634 |
* no TearDown function present in the suite the function will return NULL. |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
635 |
* |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
636 |
* \param suite Used test suite |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
637 |
* |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
638 |
* \return Function pointer to test case's tear down function |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
639 |
*/ |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
640 |
TestCaseTearDownFp |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
641 |
LoadTestTearDownFunction(void *suite) { |
5764
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
642 |
return (TestCaseTearDownFp) SDL_LoadFunction(suite, "TearDown"); |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
643 |
} |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
644 |
|
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
645 |
|
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
646 |
/*! |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
647 |
* Loads function that initialises the test environment for |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
648 |
* a test case in the given suite. |
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
649 |
* |
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
650 |
* \param suite Used test suite |
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
651 |
* |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
652 |
* \return Function pointer (InitTestInvironmentFp) which points to loaded init function. NULL if function fails. |
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
653 |
*/ |
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
654 |
InitTestInvironmentFp |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
655 |
LoadInitTestInvironmentFunction(void *suite) { |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
656 |
InitTestInvironmentFp testEnvInit = (InitTestInvironmentFp) SDL_LoadFunction(suite, "_InitTestEnvironment"); |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
657 |
if(testEnvInit == NULL) { |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
658 |
fprintf(stderr, "Loading _InitTestInvironment function failed, testEnvInit == NULL\n"); |
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
659 |
fprintf(stderr, "%s\n", SDL_GetError()); |
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
660 |
} |
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
661 |
|
5754
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
662 |
return testEnvInit; |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
663 |
} |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
664 |
|
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
665 |
|
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
666 |
/*! |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
667 |
* Loads function that deinitialises the test environment (and returns |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
668 |
* the test case's result) created for the test case in the given suite. |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
669 |
* |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
670 |
* \param suite Used test suite |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
671 |
* |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
672 |
* \return Function pointer (QuitTestInvironmentFp) which points to loaded init function. NULL if function fails. |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
673 |
*/ |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
674 |
QuitTestInvironmentFp |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
675 |
LoadQuitTestInvironmentFunction(void *suite) { |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
676 |
QuitTestInvironmentFp testEnvQuit = (QuitTestInvironmentFp) SDL_LoadFunction(suite, "_QuitTestEnvironment"); |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
677 |
if(testEnvQuit == NULL) { |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
678 |
fprintf(stderr, "Loading _QuitTestEnvironment function failed, testEnvQuit == NULL\n"); |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
679 |
fprintf(stderr, "%s\n", SDL_GetError()); |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
680 |
} |
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
681 |
|
2eead798346a
Added SetUp/TearDown functions for test suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5751
diff
changeset
|
682 |
return testEnvQuit; |
5678
50401a6c3c95
Refactoring the TestCaseInit and TestCaseQuit functions
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5677
diff
changeset
|
683 |
} |
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
684 |
|
5770
795a59de1ad5
Fixes to logging system.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5769
diff
changeset
|
685 |
|
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
686 |
/*! |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
687 |
* Loads function that returns failed assert count in the current |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
688 |
* test environment |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
689 |
* |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
690 |
* \param suite Used test suite |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
691 |
* |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
692 |
* \return Function pointer to _CountFailedAsserts function |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
693 |
*/ |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
694 |
CountFailedAssertsFp |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
695 |
LoadCountFailedAssertsFunction(void *suite) { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
696 |
CountFailedAssertsFp countFailedAssert = (CountFailedAssertsFp) SDL_LoadFunction(suite, "_CountFailedAsserts"); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
697 |
if(countFailedAssert == NULL) { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
698 |
fprintf(stderr, "Loading _CountFailedAsserts function failed, countFailedAssert == NULL\n"); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
699 |
fprintf(stderr, "%s\n", SDL_GetError()); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
700 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
701 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
702 |
return countFailedAssert; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
703 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
704 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
705 |
|
5764
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
706 |
/*! |
5768
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
707 |
* Set timeout for test. |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
708 |
* |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
709 |
* \param timeout Timeout interval in seconds! |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
710 |
* \param callback Function that will be called after timeout has elapsed |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
711 |
*/ |
5775
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
712 |
void |
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
713 |
SetTestTimeout(int timeout, void (*callback)(int)) |
5768
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
714 |
{ |
5769
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
715 |
if(callback == NULL) { |
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
716 |
fprintf(stderr, "Error: timeout callback can't be NULL"); |
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
717 |
} |
5775
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
718 |
|
5769
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
719 |
if(timeout < 0) { |
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
720 |
fprintf(stderr, "Error: timeout value must be bigger than zero."); |
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
721 |
} |
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
722 |
|
5775
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
723 |
int tm = (timeout > universal_timeout ? timeout : universal_timeout); |
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
724 |
|
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
725 |
#if 1 |
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
726 |
/* Init SDL timer if not initialized before */ |
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
727 |
if(SDL_WasInit(SDL_INIT_TIMER) == 0) { |
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
728 |
if(SDL_InitSubSystem(SDL_INIT_TIMER)) { |
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
729 |
fprintf(stderr, "Error: Failed to init timer subsystem"); |
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
730 |
fprintf(stderr, "%s\n", SDL_GetError()); |
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
731 |
} |
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
732 |
} |
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
733 |
|
5768
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
734 |
/* Note: |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
735 |
* SDL_Init(SDL_INIT_TIMER) should be successfully called before using this |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
736 |
*/ |
5775
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
737 |
int timeoutInMilliseconds = tm * 1000; |
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
738 |
|
5809
adc13772de72
Fixed a bunch of compiler warnings.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5808
diff
changeset
|
739 |
SDL_TimerID timerID = SDL_AddTimer(timeoutInMilliseconds, (SDL_TimerCallback) callback, 0x0); |
adc13772de72
Fixed a bunch of compiler warnings.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5808
diff
changeset
|
740 |
if(timerID == 0) { |
5768
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
741 |
fprintf(stderr, "Error: Creation of SDL timer failed.\n"); |
5775
61b87cd64b4d
Using SDL timer to kill hung tests.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5773
diff
changeset
|
742 |
fprintf(stderr, "Error: %s\n", SDL_GetError()); |
5768
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
743 |
} |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
744 |
#else |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
745 |
signal(SIGALRM, callback); |
5769
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
746 |
alarm((unsigned int) tm); |
5768
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
747 |
#endif |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
748 |
} |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
749 |
|
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
750 |
|
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
751 |
/*! |
5764
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
752 |
* Kills test that hungs. Test hungs when its execution |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
753 |
* takes longer than timeout specified for it. |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
754 |
* |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
755 |
* When test will be killed SIG_ALRM will be triggered and |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
756 |
* it'll call this function which kills the test process. |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
757 |
* |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
758 |
* Note: if runner is executed with --in-proc then hung tests |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
759 |
* can't be killed |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
760 |
* |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
761 |
* \param signum |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
762 |
*/ |
5769
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
763 |
void |
8f51d6a55006
Added --timeout VALUE command option.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5768
diff
changeset
|
764 |
KillHungTestInChildProcess(int signum) |
5768
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
765 |
{ |
5809
adc13772de72
Fixed a bunch of compiler warnings.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5808
diff
changeset
|
766 |
(void)signum; // keeps the compiler silent about unused variable |
adc13772de72
Fixed a bunch of compiler warnings.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5808
diff
changeset
|
767 |
|
5764
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
768 |
exit(TEST_RESULT_KILLED); |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
769 |
} |
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
770 |
|
5773
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
771 |
/*! |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
772 |
* Checks if given test case can be executed on the current platform. |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
773 |
* |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
774 |
* \param testCase Test to be checked |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
775 |
* \returns 1 if test is runnable, otherwise 0. On error returns -1 |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
776 |
*/ |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
777 |
int |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
778 |
CheckTestRequirements(TestCase *testCase) |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
779 |
{ |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
780 |
int retVal = 1; |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
781 |
|
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
782 |
if(testCase == NULL) { |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
783 |
fprintf(stderr, "TestCase parameter can't be NULL"); |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
784 |
return -1; |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
785 |
} |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
786 |
|
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
787 |
if(testCase->requirements & TEST_REQUIRES_AUDIO) { |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
788 |
retVal = PlatformSupportsAudio(); |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
789 |
} |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
790 |
|
5821
717e4cb840dd
Ported rwops test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5811
diff
changeset
|
791 |
if(testCase->requirements & TEST_REQUIRES_STDIO) { |
717e4cb840dd
Ported rwops test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5811
diff
changeset
|
792 |
retVal = PlatformSupportsStdio(); |
717e4cb840dd
Ported rwops test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5811
diff
changeset
|
793 |
} |
717e4cb840dd
Ported rwops test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5811
diff
changeset
|
794 |
|
717e4cb840dd
Ported rwops test suite.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5811
diff
changeset
|
795 |
|
5773
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
796 |
return retVal; |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
797 |
} |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
798 |
|
5764
5cf913feab69
Fixed logging noise coming from unimplemented optional test
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5759
diff
changeset
|
799 |
|
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
800 |
/* |
5759
59615ddece72
Fixed AssertEquals.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5758
diff
changeset
|
801 |
* Execute a test. Loads the test, executes it and |
59615ddece72
Fixed AssertEquals.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5758
diff
changeset
|
802 |
* returns the tests return value to the caller. |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
803 |
* |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
804 |
* \param testItem Test to be executed |
5759
59615ddece72
Fixed AssertEquals.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5758
diff
changeset
|
805 |
* \param test result |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
806 |
*/ |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
807 |
int |
5797
4936c840d128
Fixing execution key generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5796
diff
changeset
|
808 |
RunTest(TestCase *testCase, Uint64 execKey) |
5768
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
809 |
{ |
5780
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
810 |
if(!testCase) { |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
811 |
return -1; |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
812 |
} |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
813 |
|
5773
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
814 |
int runnable = CheckTestRequirements(testCase); |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
815 |
if(runnable != 1) { |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
816 |
return TEST_RESULT_SKIPPED; |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
817 |
} |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
818 |
|
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
819 |
if(testCase->timeout > 0 || universal_timeout > 0) { |
5768
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
820 |
if(execute_inproc) { |
5770
795a59de1ad5
Fixes to logging system.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5769
diff
changeset
|
821 |
Log(time(0), "Test asked for timeout which is not supported."); |
5768
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
822 |
} |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
823 |
else { |
5773
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
824 |
SetTestTimeout(testCase->timeout, KillHungTestInChildProcess); |
5768
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
825 |
} |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
826 |
} |
40d331dc9c9e
Refactored a bit.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5767
diff
changeset
|
827 |
|
5797
4936c840d128
Fixing execution key generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5796
diff
changeset
|
828 |
testCase->initTestEnvironment(execKey); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
829 |
|
5773
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
830 |
if(testCase->testSetUp) { |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
831 |
testCase->testSetUp(0x0); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
832 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
833 |
|
5773
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
834 |
int cntFailedAsserts = testCase->countFailedAsserts(); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
835 |
if(cntFailedAsserts != 0) { |
5758
e497802a71b4
Harness kills hung tests (won't work with --in-proc option).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5755
diff
changeset
|
836 |
return TEST_RESULT_SETUP_FAILURE; |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
837 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
838 |
|
5773
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
839 |
testCase->testCase(0x0); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
840 |
|
5773
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
841 |
if(testCase->testTearDown) { |
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
842 |
testCase->testTearDown(0x0); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
843 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
844 |
|
5773
a610795fd8fe
Refined test skipping.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5772
diff
changeset
|
845 |
return testCase->quitTestEnvironment(); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
846 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
847 |
|
5758
e497802a71b4
Harness kills hung tests (won't work with --in-proc option).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5755
diff
changeset
|
848 |
|
e497802a71b4
Harness kills hung tests (won't work with --in-proc option).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5755
diff
changeset
|
849 |
/*! |
5759
59615ddece72
Fixed AssertEquals.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5758
diff
changeset
|
850 |
* Sets up a test case. Decideds wheter the test will |
59615ddece72
Fixed AssertEquals.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5758
diff
changeset
|
851 |
* be executed in-proc or out-of-proc. |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
852 |
* |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
853 |
* \param testItem The test case that will be executed |
5826
ac41301850c1
Fixed the doxygen markup.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5821
diff
changeset
|
854 |
* \param execKey Execution key for the test case |
ac41301850c1
Fixed the doxygen markup.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5821
diff
changeset
|
855 |
* |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
856 |
* \return The return value of the test. Zero means success, non-zero failure. |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
857 |
*/ |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
858 |
int |
5797
4936c840d128
Fixing execution key generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5796
diff
changeset
|
859 |
ExecuteTest(TestCase *testItem, Uint64 execKey) { |
5758
e497802a71b4
Harness kills hung tests (won't work with --in-proc option).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5755
diff
changeset
|
860 |
int retVal = -1; |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
861 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
862 |
if(execute_inproc) { |
5780
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
863 |
retVal = RunTest(testItem, execKey); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
864 |
} else { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
865 |
int childpid = fork(); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
866 |
if(childpid == 0) { |
5780
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
867 |
exit(RunTest(testItem, execKey)); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
868 |
} else { |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
869 |
int stat_lock = -1; |
5809
adc13772de72
Fixed a bunch of compiler warnings.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5808
diff
changeset
|
870 |
wait(&stat_lock); |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
871 |
|
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
872 |
retVal = HandleChildProcessReturnValue(stat_lock); |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
873 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
874 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
875 |
|
5780
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
876 |
if(retVal == TEST_RESULT_SKIPPED) { |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
877 |
testSkipCount++; |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
878 |
totalTestSkipCount++; |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
879 |
} |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
880 |
else if(retVal) { |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
881 |
totalTestFailureCount++; |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
882 |
testFailureCount++; |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
883 |
} |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
884 |
else { |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
885 |
totalTestPassCount++; |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
886 |
testPassCount++; |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
887 |
} |
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
888 |
|
6d294a397a27
Adding elementary support for fuzzing.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5775
diff
changeset
|
889 |
// return the value for logger |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
890 |
return retVal; |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
891 |
} |
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
892 |
|
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
893 |
|
5671
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
894 |
/*! |
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
895 |
* If using out-of-proc execution of tests. This function |
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
896 |
* will handle the return value of the child process |
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
897 |
* and interprets it to the runner. Also prints warnings |
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
898 |
* if child was aborted by a signela. |
5671
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
899 |
* |
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
900 |
* \param stat_lock information about the exited child process |
5671
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
901 |
* |
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
902 |
* \return 0 if test case succeeded, 1 otherwise |
5671
5b0e288921eb
Added doxygen-compatible comments
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5670
diff
changeset
|
903 |
*/ |
5673
07b920bcff70
Fixed doxygen warnings
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5672
diff
changeset
|
904 |
int |
5694
2fc30d9b1002
Added comments and did some cleaning.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5693
diff
changeset
|
905 |
HandleChildProcessReturnValue(int stat_lock) |
5673
07b920bcff70
Fixed doxygen warnings
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5672
diff
changeset
|
906 |
{ |
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
907 |
int returnValue = -1; |
5659
37e7b3b4b5e3
Bootstrapping build process using proof-of-concept test runner.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff
changeset
|
908 |
|
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
909 |
if(WIFEXITED(stat_lock)) { |
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
910 |
returnValue = WEXITSTATUS(stat_lock); |
5667
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
911 |
} else if(WIFSIGNALED(stat_lock)) { |
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
912 |
int signal = WTERMSIG(stat_lock); |
5751
cbb921210496
Bunch of little fixes.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5746
diff
changeset
|
913 |
// \todo add this to logger (add signal number) |
5770
795a59de1ad5
Fixes to logging system.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5769
diff
changeset
|
914 |
Log(time(0), "FAILURE: test was aborted due to %d\n", signal); |
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
915 |
returnValue = 1; |
5667
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
916 |
} |
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
917 |
|
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
918 |
return returnValue; |
5667
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
919 |
} |
4c0d0d32414c
Refactoring the massive main() to smaller functions.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5666
diff
changeset
|
920 |
|
5682
a04cb565aed2
Possible to execute only selected tests or suites.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5681
diff
changeset
|
921 |
|
5672
d2df9dbce0ea
Refactoring the code (runner.c).
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5671
diff
changeset
|
922 |
/*! |
5794
e39e9c62c671
Fixed harness seed generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5793
diff
changeset
|
923 |
* Generates a random run seed for the harness. Seed |
e39e9c62c671
Fixed harness seed generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5793
diff
changeset
|
924 |
* can contain characters 0-9A-Z |
5786
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
925 |
* |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
926 |
* \param length The length of the generated seed |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
927 |
* |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
928 |
* \returns The generated seed |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
929 |
*/ |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
930 |
char * |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
931 |
GenerateRunSeed(const int length) |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
932 |
{ |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
933 |
if(length <= 0) { |
5787
46cddba50600
Logger logs to file on default.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5786
diff
changeset
|
934 |
fprintf(stderr, "Error: length of the harness seed can't be less than zero\n"); |
5786
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
935 |
return NULL; |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
936 |
} |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
937 |
|
5794
e39e9c62c671
Fixed harness seed generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5793
diff
changeset
|
938 |
char *seed = SDL_malloc((length + 1) * sizeof(char)); |
5786
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
939 |
if(seed == NULL) { |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
940 |
fprintf(stderr, "Error: malloc for run seed failed\n"); |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
941 |
return NULL; |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
942 |
} |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
943 |
|
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
944 |
RND_CTX randomContext; |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
945 |
|
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
946 |
utl_randomInitTime(&randomContext); |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
947 |
|
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
948 |
int counter = 0; |
5794
e39e9c62c671
Fixed harness seed generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5793
diff
changeset
|
949 |
for( ; counter < length - 1; ++counter) { |
5786
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
950 |
int number = abs(utl_random(&randomContext)); |
5794
e39e9c62c671
Fixed harness seed generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5793
diff
changeset
|
951 |
char ch = (char) (number % (91 - 48)) + 48; |
5788
eeb5431a8cbf
Made run seed more file name friendly.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5787
diff
changeset
|
952 |
|
eeb5431a8cbf
Made run seed more file name friendly.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5787
diff
changeset
|
953 |
if(ch >= 58 && ch <= 64) { |
eeb5431a8cbf
Made run seed more file name friendly.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5787
diff
changeset
|
954 |
ch = 65; |
eeb5431a8cbf
Made run seed more file name friendly.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5787
diff
changeset
|
955 |
} |
eeb5431a8cbf
Made run seed more file name friendly.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5787
diff
changeset
|
956 |
|
eeb5431a8cbf
Made run seed more file name friendly.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5787
diff
changeset
|
957 |
seed[counter] = ch; |
5786
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
958 |
} |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
959 |
|
5788
eeb5431a8cbf
Made run seed more file name friendly.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5787
diff
changeset
|
960 |
seed[counter] = '\0'; |
eeb5431a8cbf
Made run seed more file name friendly.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5787
diff
changeset
|
961 |
|
5786
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
962 |
return seed; |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
963 |
} |
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
964 |
|
b6df0fc13504
Added randomly generated harness seed.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5785
diff
changeset
|
965 |
/*! |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
966 |
* Sets up the logger. |
5681
7abfcc71aa7d
Runner can execute multiple test suites consecutively.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5680
diff
changeset
|
967 |
* |
5785
7fc252ce5d1d
Added simple logging levels to logging system.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5784
diff
changeset
|
968 |
* \return Logger data structure (that needs be deallocated) |
5681
7abfcc71aa7d
Runner can execute multiple test suites consecutively.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5680
diff
changeset
|
969 |
*/ |
5794
e39e9c62c671
Fixed harness seed generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5793
diff
changeset
|
970 |
LoggerData * |
5795
134c0f7ae826
Changed SetUpLogger based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5794
diff
changeset
|
971 |
SetUpLogger(const int log_stdout_enabled, const int xml_enabled, const int xsl_enabled, |
5843
66dc563da07e
Fixed timestamp issue.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5842
diff
changeset
|
972 |
const int custom_xsl_enabled, const char *defaultXslSheet, const time_t timestamp) |
5755
35d4ae5dea90
If any assert in SetUp function fails that test will be skipped.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5754
diff
changeset
|
973 |
{ |
5794
e39e9c62c671
Fixed harness seed generation based on CR.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5793
diff
changeset
|
974 |
LoggerData *loggerData = SDL_malloc(sizeof(LoggerData)); |
5785
7fc252ce5d1d
Added simple logging levels to logging system.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5784
diff
changeset
|
975 |
if(loggerData == NULL) { |
7fc252ce5d1d
Added simple logging levels to logging system.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5784
diff
changeset
|
976 |
fprintf(stderr, "Error: Logger data structure not allocated."); |
7fc252ce5d1d
Added simple logging levels to logging system.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5784
diff
changeset
|
977 |
return NULL; |
7fc252ce5d1d
Added simple logging levels to logging system.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5784
diff
changeset
|
978 |
} |
5788
eeb5431a8cbf
Made run seed more file name friendly.
Markus Kauppila <markus.kauppila@gmail.com>
parents:
5787
diff
changeset
|
979 |
memset(loggerData, 0, sizeof(LoggerData)); |