Changeset 6799

Show
Ignore:
Timestamp:
07/09/10 16:00:39 (21 months ago)
Author:
westram
Message:
  • test against I/O errors
Location:
branches/refactor/UNIT_TESTER
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/refactor/UNIT_TESTER/test_global.h

    r6798 r6799  
    130130            TRIGGER_ASSERTION(); // fake an assertion failure 
    131131        } 
     132        static void ioerrorf(const char *filename, int lineno, const char *format, ...) __attribute__((format(printf, 3, 4))) { 
     133            FlushedOutput yes; 
     134            fprintf(stderr, "%s:%i: Error: ", filename, lineno); 
     135            VPRINTFORMAT(format); 
     136            fprintf(stderr, " (errno=%i='%s')", errno, strerror(errno)); 
     137            fputc('\n', stderr); 
     138            TRIGGER_ASSERTION(); // fake an assertion failure 
     139        } 
    132140#undef VPRINTFORMAT 
    133141    }; 
  • branches/refactor/UNIT_TESTER/test_unit.h

    r6798 r6799  
    1919#include <cstdarg> 
    2020#endif 
     21#ifndef ERRNO_H 
     22#include <errno.h> 
     23#endif 
    2124 
    2225#define ENABLE_CRASH_TESTS // comment out this line to get rid of provoked SEGVs (e.g. while debugging test-code) 
     
    153156        return is_similar(d1, d2, 0.000001); 
    154157    } 
     158 
     159     
    155160 
    156161    inline bool files_are_equal(const char *file1, const char *file2) { 
     
    242247#define TEST_ERROR(format,strarg)           arb_test::FlushedOutput::errorf(__FILE__, __LINE__, format, (strarg)) 
    243248#define TEST_ERROR2(format,strarg1,strarg2) arb_test::FlushedOutput::errorf(__FILE__, __LINE__, format, (strarg1), (strarg2)) 
     249#define TEST_IOERROR(format,strarg)         arb_test::FlushedOutput::ioerrorf(__FILE__, __LINE__, format, (strarg)) 
    244250 
    245251// -------------------------------------------------------------------------------- 
     
    258264#define TEST_ASSERT_ZERO(cond)         TEST_ASSERT((cond)         == 0) 
    259265#define TEST_ASSERT_ZERO__BROKEN(cond) TEST_ASSERT__BROKEN((cond) == 0) 
     266 
     267#define TEST_ASSERT_ZERO_OR_SHOW_ERRNO(iocond)                  \ 
     268    do {                                                        \ 
     269        if (!(iocond))                                          \ 
     270            TEST_IOERROR("I/O-failure in '%s'", #iocond);       \ 
     271    } while(0) 
    260272 
    261273// --------------------------------------------------------------------------------