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

Last change on this file since 183 was 172, checked in by katerina, 16 years ago

Documentation update, more dnmalloc fixes.

  • Property svn:executable set to *
File size: 1.7 KB
RevLine 
[17]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
[19]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
[17]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
23'
24
25cat $FILES | grep '^void Test' |
26 sed -e 's/(.*$//' \
27 -e 's/$/(CuTest*);/' \
28 -e 's/^/extern /'
29
30echo \
31'
32
[19]33int RunAllTests(void)
[17]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);
[19]50 if (suite->failCount > 0)
[29]51 fprintf(stderr, "%s%c", output->buffer, 0x0A);
[19]52 else
[29]53 fprintf(stdout, "%s%c", output->buffer, 0x0A);
[19]54 return suite->failCount;
[17]55}
56
57int main(void)
58{
[172]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
[171]64#if !defined(USE_SYSTEM_MALLOC) && defined(USE_MALLOC_LOCK)
65 extern int dnmalloc_pthread_init(void);
66 dnmalloc_pthread_init();
67#endif
[172]68#if !defined(USE_SYSTEM_MALLOC)
69 (void) dnmalloc_set_handler(safe_fatal);
70#endif
[19]71 int retval;
72 retval = RunAllTests();
73 return (retval == 0) ? 0 : 1;
[17]74}
75'
Note: See TracBrowser for help on using the repository browser.