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

Last change on this file since 383 was 292, checked in by katerina, 14 years ago

Fix for compile problems on Solaris 10 (ticket #220).

  • 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 "config.h"
21#include <stdio.h>
22#include "CuTest.h"
23'
24
25cat $FILES | grep '^void Test' |
26 sed -e 's/(.*$//' \
27 -e 's/$/(CuTest*);/' \
28 -e 's/^/extern /'
29
30echo \
31'
32
33int RunAllTests(void)
34{
35 CuString *output = CuStringNew();
36 CuSuite* suite = CuSuiteNew();
37
38'
39cat $FILES | grep '^void Test' |
40 sed -e 's/^void //' \
41 -e 's/(.*$//' \
42 -e 's/^/ SUITE_ADD_TEST(suite, /' \
43 -e 's/$/);/'
44
45echo \
46'
47 CuSuiteRun(suite);
48 CuSuiteSummary(suite, output);
49 CuSuiteDetails(suite, output);
50 if (suite->failCount > 0)
51 fprintf(stderr, "%s%c", output->buffer, 0x0A);
52 else
53 fprintf(stdout, "%s%c", output->buffer, 0x0A);
54 return suite->failCount;
55}
56
57int main(void)
58{
59#if !defined(USE_SYSTEM_MALLOC)
60 typedef void assert_handler_tp(const char * error, const char *file, int line);
61 extern assert_handler_tp *dnmalloc_set_handler(assert_handler_tp *new);
62 extern void safe_fatal (const char * details, const char *f, int l);
63#endif
64#if !defined(USE_SYSTEM_MALLOC) && defined(USE_MALLOC_LOCK)
65 extern int dnmalloc_pthread_init(void);
66 dnmalloc_pthread_init();
67#endif
68#if !defined(USE_SYSTEM_MALLOC)
69 (void) dnmalloc_set_handler(safe_fatal);
70#endif
71 int retval;
72 retval = RunAllTests();
73 return (retval == 0) ? 0 : 1;
74}
75'
Note: See TracBrowser for help on using the repository browser.