"Fossies" - the Fresh Open Source Software Archive

Member "vfplot-1.0.15/src/unit/main.c" (6 Nov 2019, 1155 Bytes) of package /linux/privat/vfplot-1.0.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "main.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.0.14_vs_1.0.15.

    1 
    2 #include <stdio.h>
    3 #include <stdlib.h>
    4 
    5 #include <CUnit/Basic.h>
    6 
    7 #include "tests.h"
    8 
    9 #define NO_STDERR
   10 
   11 #ifdef NO_STDERR
   12 #include <fcntl.h>
   13 #include <unistd.h>
   14 #endif
   15 
   16 int main(void)
   17 {
   18   CU_BasicRunMode mode = CU_BRM_VERBOSE;
   19   CU_ErrorAction error_action = CUEA_IGNORE;
   20   setvbuf(stdout, NULL, _IONBF, 0);
   21 
   22   if (CU_initialize_registry())
   23     {
   24       fprintf(stderr,"failed to initialise registry\n");
   25       return EXIT_FAILURE;
   26     }
   27 
   28   tests_load();
   29   CU_basic_set_mode(mode);
   30   CU_set_error_action(error_action);
   31 
   32 #ifdef NO_STDERR
   33 
   34   int devnull = open("/dev/null", O_RDWR|O_CREAT|O_APPEND, 0600);
   35   int save_err = dup(fileno(stderr));
   36 
   37   if (dup2(devnull, fileno(stderr)) == -1)
   38     {
   39       printf("failed to redirect stderr\n");
   40       return EXIT_FAILURE;
   41     }
   42 
   43 #endif
   44 
   45   int status = CU_basic_run_tests();
   46 
   47 #ifdef NO_STDERR
   48 
   49   fflush(stderr);
   50   close(devnull);
   51 
   52   dup2(save_err, fileno(stderr));
   53   close(save_err);
   54 
   55 #endif
   56 
   57   int nfail = CU_get_number_of_failures();
   58 
   59   printf("\nSuite %s: %d failed\n",
   60          (status == 0 ? "OK" : "errored"),
   61          nfail);
   62 
   63   CU_cleanup_registry();
   64 
   65   return (nfail > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
   66 }