diff --git a/nc_test/CMakeLists.txt b/nc_test/CMakeLists.txt index ae4e81cf9..3831cbefe 100644 --- a/nc_test/CMakeLists.txt +++ b/nc_test/CMakeLists.txt @@ -20,16 +20,6 @@ TARGET_LINK_LIBRARIES(nc_test ${HAVE_LIBM} ) - -## -# The difficulties around tst_swap4b are easier solved if we -# include ncx.c directly and not try to coax the functionality -# out of libnetcdf. -## -ADD_EXECUTABLE(tst_swap4b tst_swap4b.c ${CMAKE_SOURCE_DIR}/libsrc/ncx.c ${CMAKE_SOURCE_DIR}/libsrc/ncx.h) -ADD_TEST(tst_swap4b ${EXECUTABLE_OUTPUT_PATH}/tst_swap4b) - - # Some extra stand-alone tests SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta) diff --git a/nc_test/Makefile.am b/nc_test/Makefile.am index 7e54b1463..606003478 100644 --- a/nc_test/Makefile.am +++ b/nc_test/Makefile.am @@ -15,9 +15,9 @@ tst_diskless3.nc tst_diskless3_file.cdl tst_diskless3_memory.cdl \ tst_diskless4.cdl tst_diskless4.nc tst_formatx.nc unlim.nc ncx.c # These are the tests which are always run. -TESTPROGRAMS = t_nc tst_small nc_test tst_swap4b tst_misc tst_norm \ +TESTPROGRAMS = t_nc tst_small nc_test tst_misc tst_norm \ tst_names tst_nofill tst_nofill2 tst_nofill3 tst_atts3 \ - tst_meta tst_swap4b + tst_meta if USE_NETCDF4 TESTPROGRAMS += tst_atts tst_put_vars @@ -32,14 +32,6 @@ endif nc_test_SOURCES = nc_test.c error.c test_get.c test_put.c \ test_read.c test_write.c util.c error.h tests.h - -## -# These are the source files for tst_swap4b. -# Note that the file 'ncx.c' lives in `libsrc/` -# and is generated by m4. -## -tst_swap4b_SOURCES = ncx.c tst_swap4b.c - LDADD = ${top_builddir}/liblib/libnetcdf.la AM_CPPFLAGS += -I$(top_builddir)/liblib -I$(top_builddir)/include -I$(top_srcdir)/libsrc @@ -99,7 +91,7 @@ EXTRA_DIST = test_get.m4 test_put.m4 run_valgrind_tests.sh \ run_diskless.sh run_diskless2.sh run_mmap.sh run_pnetcdf_test.sh # ref_tst_diskless2.cdl is for diff comparison and to produce tst_diskless2.c -EXTRA_DIST += ref_tst_diskless2.cdl CMakeLists.txt tst_swap4b.c +EXTRA_DIST += ref_tst_diskless2.cdl CMakeLists.txt # Only clean these on mainatiner-clean, because they require m4 to # regenerate. diff --git a/nc_test/tst_swap4b.c b/nc_test/tst_swap4b.c deleted file mode 100644 index 948e80aab..000000000 --- a/nc_test/tst_swap4b.c +++ /dev/null @@ -1,123 +0,0 @@ -/*! Test swap4b function. - * - * Test added July 27, 2015. - * - * This test confirms that the function ncx.c:swap4b() is - * working properly. For more information regarding this test - * and the circumstances prompting it, see - * https://bugtracking.unidata.ucar.edu/browse/NCF-338 - */ - -#include "netcdf.h" - -#define SWAP4(a) ( ((a) << 24) | \ - (((a) << 8) & 0x00ff0000) | \ - (((a) >> 8) & 0x0000ff00) | \ - (((a) >> 24) & 0x000000ff) ) - -/* Taken from ncx.c */ -void swap4b(void *dst, const void *src); - -#include - -/*! The 'Old' swap4b algorithm. - * The naive algorithm. Replicated here to test - * CPU bounds. - */ -void old_swap4b(void *dst, const void *src) { - char *op = dst; - const char *ip = src; - op[0] = ip[3]; - op[1] = ip[2]; - op[2] = ip[1]; - op[3] = ip[0]; -} - -int main() { - - - unsigned int first = 0x0000ffff; - unsigned int check_first = 0xffff0000; - - unsigned int second = 0xffff0000; - unsigned int check_second = 0x0000ffff; - - unsigned int third = 0x00abcdef; - unsigned int check_third = 0xefcdab00; - - unsigned int rev_first = 0; - unsigned int rev_second = 0; - unsigned int rev_third = 0; - - printf("\n"); - printf("First:\t0x%08x...\n",first); - printf("Second:\t0x%08x...\n",second); - printf("Third:\t0x%08x...\n",third); - - printf("\nReversing Unsigned Integers with old swap4b\n"); - old_swap4b(&rev_first,&first); - old_swap4b(&rev_second,&second); - old_swap4b(&rev_third,&third); - - printf("1. Reversing 0x%08x: 0x%08x ...\t",first,rev_first); - if(rev_first == check_first) { - printf("Success!\n"); - } else { - printf("Failure!\n"); - return -1; - } - - printf("2. Reversing 0x%08x: 0x%08x ...\t",second,rev_second); - if(rev_second == check_second) { - printf("Success!\n"); - } else { - printf("Failure!\n"); - return -1; - } - - printf("3. Reversing 0x%08x: 0x%08x ...\t",third,rev_third); - if(rev_third == check_third) { - printf("Success!\n"); - } else { - printf("Failure!\n"); - return -1; - } - - /* Zero out results, check with bit-shifting swap4b. */ - rev_first = 0; - rev_second = 0; - rev_third = 0; - - printf("\nReversing Unsigned Integers with new swap4b\n"); - swap4b(&rev_first,&first); - swap4b(&rev_second,&second); - swap4b(&rev_third,&third); - - printf("1. Reversing 0x%08x: 0x%08x ...\t",first,rev_first); - if(rev_first == check_first) { - printf("Success!\n"); - } else { - printf("Failure!\n"); - return -1; - } - - printf("2. Reversing 0x%08x: 0x%08x ...\t",second,rev_second); - if(rev_second == check_second) { - printf("Success!\n"); - } else { - printf("Failure!\n"); - return -1; - } - - printf("3. Reversing 0x%08x: 0x%08x ...\t",third,rev_third); - if(rev_third == check_third) { - printf("Success!\n"); - } else { - printf("Failure!\n"); - return -1; - } - - printf("\nFinished.\n"); - return 0; - -}