source: trunk/src/make-tests.sh@ 255

Last change on this file since 255 was 203, checked in by katerina, 16 years ago

Fix compile failures on RHEL3 (ticket #130) and FreeBSD7 amd64 (ticket #131).

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#!/bin/sh
2
3# Auto generate single AllTests file for CuTest.
4# Searches through all *.c files in the current directory.
5# Prints to stdout.
6# Author: Asim Jalis
7# Date: 01/08/2003
8
9# Modified to return non-zero if any test has failed
10# Rainer Wichmann, 29. Jan 2006
11# ...and to print to stderr if any test has failed
12# Rainer Wichmann, 31. Jan 2006
13
14if test $# -eq 0 ; then FILES=*.c ; else FILES=$* ; fi
15
16echo '
17
18/* This is auto-generated code. Edit at your own peril. */
19
20#include <stdio.h>
21#include "CuTest.h"
22#include "config.h"
23
24'
25
26cat $FILES | grep '^void Test' |
27 sed -e 's/(.*$//' \
28 -e 's/$/(CuTest*);/' \
29 -e 's/^/extern /'
30
31echo \
32'
33
34int RunAllTests(void)
35{
36 CuString *output = CuStringNew();
37 CuSuite* suite = CuSuiteNew();
38
39'
40cat $FILES | grep '^void Test' |
41 sed -e 's/^void //' \
42 -e 's/(.*$//' \
43 -e 's/^/ SUITE_ADD_TEST(suite, /' \
44 -e 's/$/);/'
45
46echo \
47'
48 CuSuiteRun(suite);
49 CuSuiteSummary(suite, output);
50 CuSuiteDetails(suite, output);
51 if (suite->failCount > 0)
52 fprintf(stderr, "%s%c", output->buffer, 0x0A);
53 else
54 fprintf(stdout, "%s%c", output->buffer, 0x0A);
55 return suite->failCount;
56}
57
58int main(void)
59{
60#if !defined(USE_SYSTEM_MALLOC)
61 typedef void assert_handler_tp(const char * error, const char *file, int line);
62 extern assert_handler_tp *dnmalloc_set_handler(assert_handler_tp *new);
63 extern void safe_fatal (const char * details, const char *f, int l);
64#endif
65#if !defined(USE_SYSTEM_MALLOC) && defined(USE_MALLOC_LOCK)
66 extern int dnmalloc_pthread_init(void);
67 dnmalloc_pthread_init();
68#endif
69#if !defined(USE_SYSTEM_MALLOC)
70 (void) dnmalloc_set_handler(safe_fatal);
71#endif
72 int retval;
73 retval = RunAllTests();
74 return (retval == 0) ? 0 : 1;
75}
76'
Note: See TracBrowser for help on using the repository browser.