/** \file \internal Basic diskless API tests. Copyright 2018, UCAR/Unidata. See COPYRIGHT file for copying and redistribution conditions. */ #define DDBG #include "config.h" #include #include #include "netcdf.h" #include "nc_tests.h" #include "err_macros.h" /* netcdf tst_diskless { variables: int resistor_value; float capacitor_value; short number_of_555_timer_chips; } */ #ifndef NC_NETCDF3 #define NC_NETCDF3 0 #endif #define FLAGS4 (NC_NETCDF4|NC_CLASSIC_MODEL) #define FLAGS3 (NC_NETCDF3) #define RESISTOR "resistor_value" #define CAPACITOR "capacitor_value" #define NUM555 "number_of_555_timer_chips" #ifdef DDBG #undef ERR void fail(int line) { fflush(stdout); fprintf(stderr,"\nfail: line=%d\n",line); fflush(stderr); exit(1); } #define ERR fail(__LINE__) #endif /* Control flags */ static int flags, persist, usenetcdf4, use_mmap, diskless; char* smode(int mode) { static char ms[8192]; ms[0] = '\0'; if(mode & NC_NETCDF4) strcat(ms,"NC_NETCDF4"); else strcat(ms,"NC_NETCDF3"); if(mode & NC_DISKLESS) strcat(ms,"|NC_DISKLESS"); if(mode & NC_WRITE) strcat(ms,"|NC_WRITE"); if(mode & NC_NOCLOBBER) strcat(ms,"|NC_NOCLOBBER"); if(mode & NC_INMEMORY) strcat(ms,"|NC_INMEMORY"); if(mode & NC_PERSIST) strcat(ms,"|NC_PERSIST"); if(mode & NC_MMAP) strcat(ms,"|NC_MMAP"); return ms; } /* Remove a file; do not care if it does not exist */ static void removefile(int persist, char* filename) { if(persist) { remove(filename); } } int main(int argc, char **argv) { int i; char* filename = "tst_diskless.nc"; /* Set defaults */ persist = 0; usenetcdf4 = 0; use_mmap = 0; diskless = 0; for(i=1;i