From c874aedd39d85d49526cd90905b4fbbc8ef7a843 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 10 Oct 2010 22:18:10 -0700 Subject: [PATCH] sparse-xarray: Convert tests to Autotest framework. --- tests/automake.mk | 2 +- tests/libpspp/sparse-xarray-test.at | 83 +++++++++++++++++++++++++++++ tests/libpspp/sparse-xarray-test.sh | 62 --------------------- 3 files changed, 84 insertions(+), 63 deletions(-) create mode 100644 tests/libpspp/sparse-xarray-test.at delete mode 100755 tests/libpspp/sparse-xarray-test.sh diff --git a/tests/automake.mk b/tests/automake.mk index 7b1e4cb8..0acfb32b 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -27,7 +27,6 @@ dist_TESTS = \ tests/formats/wkday-in.sh \ tests/formats/wkday-out.sh \ tests/formats/360.sh \ - tests/libpspp/sparse-xarray-test.sh \ tests/output/paper-size.sh \ tests/expressions/randist.sh \ tests/expressions/valuelabel.sh \ @@ -361,6 +360,7 @@ TESTSUITE_AT = \ tests/libpspp/range-map.at \ tests/libpspp/range-set.at \ tests/libpspp/sparse-array.at \ + tests/libpspp/sparse-xarray-test.at \ tests/libpspp/str.at \ tests/libpspp/string-map.at \ tests/libpspp/stringi-map.at \ diff --git a/tests/libpspp/sparse-xarray-test.at b/tests/libpspp/sparse-xarray-test.at new file mode 100644 index 00000000..4ff7d3d8 --- /dev/null +++ b/tests/libpspp/sparse-xarray-test.at @@ -0,0 +1,83 @@ +AT_BANNER([sparse external arrays]) + +m4_divert_push([PREPARE_TESTS]) +[sparse_xarray_queue_limit () { + # Each on-disk sparse_xarray eats up a file descriptor, so for the + # tests that involve on-disk sparse_xarrays we need to limit the + # maximum length of the queue. Figure out how many file descriptors + # we can let the test program open at once. + OPEN_MAX=`getconf OPEN_MAX 2>/dev/null` + case $OPEN_MAX in + [0-9]*) + # Divide by 2 because some fds are used by other code. + queue_limit=`expr $OPEN_MAX / 2` + ;; + undefined) + # Assume that any system with a dynamic fd limit has a large limit. + queue_limit=500 + ;; + *) + case `uname -m 2>/dev/null` in + CYGWIN*) + # Cygwin claims a 256-fd limit as OPEN_MAX in . + queue_limit=128 + ;; + MINGW*) + # The following email claims that Mingw should have a + # 2048-fd limit: + # http://www.mail-archive.com/squid-users@squid-cache.org/msg35249.html + queue_limit=1024 + ;; + *) + # This seems fairly conservative these days. + queue_limit=50 + ;; + esac + ;; + esac + echo "$queue_limit" +}] +m4_divert_pop([PREPARE_TESTS]) + +AT_SETUP([in-memory sparse_xarray]) +dnl --values=3 would be a slightly better test but takes much longer. +AT_CHECK([sparse-xarray-test$EXEEXT \ + --verbosity=0 --queue-limit=`sparse_xarray_queue_limit` \ + --columns=3 --max-rows=3 --max-memory-rows=3 --values=2], + [0], [ignore], [ignore]) +AT_CLEANUP + +m4_define([SPARSE_XARRAY_ON_DISK], + [AT_SETUP([on-disk sparse_xarray]) + AT_CHECK([sparse-xarray-test$EXEEXT \ + --verbosity=0 --queue-limit=`sparse_xarray_queue_limit` \ + --columns=2 --max-rows=3 --max-memory-rows=$1 --values=2], + [0], [ignore], [ignore]) + AT_CLEANUP]) +SPARSE_XARRAY_ON_DISK([0]) +SPARSE_XARRAY_ON_DISK([1]) +SPARSE_XARRAY_ON_DISK([2]) + +AT_SETUP([copying between in-memory sparse_xarrays]) +AT_KEYWORDS([sparse_xarray]) +AT_CHECK([sparse-xarray-test$EXEEXT \ + --verbosity=0 --queue-limit=`sparse_xarray_queue_limit` \ + --columns=2 --max-rows=2 --max-memory-rows=2 --values=2 \ + --xarrays=2 --no-write-rows --no-copy-columns], + [0], [ignore], [ignore]) +AT_CLEANUP + +m4_define([SPARSE_XARRAY_COPY_DISK], + [AT_SETUP([copying between on-disk sparse_xarrays]) + AT_KEYWORDS([sparse_xarray]) + limit=`sparse_xarray_queue_limit` + AT_CHECK([sparse-xarray-test$EXEEXT \ + --verbosity=0 --queue-limit=`expr $limit / 2` \ + --columns=1 --max-rows=2 --max-memory-rows=$max_memory_rows \ + --values=2 --xarrays=2 --no-write-rows --no-copy-columns], + [0], [ignore], [ignore]) + AT_CLEANUP]) +dnl These parameters are ridiculously low, but it's necessary +dnl unless we want the tests to take a very long time. +SPARSE_XARRAY_COPY_DISK([0]) +SPARSE_XARRAY_COPY_DISK([1]) diff --git a/tests/libpspp/sparse-xarray-test.sh b/tests/libpspp/sparse-xarray-test.sh deleted file mode 100755 index 71829dbd..00000000 --- a/tests/libpspp/sparse-xarray-test.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -# This program tests the sparse_xarray abstract data type implementation. - -set -e - -: ${top_builddir:=.} -RUN_TEST="${top_builddir}/tests/libpspp/sparse-xarray-test$EXEEXT --verbosity=0" - -# Each on-disk sparse_xarray eats up a file descriptor, so for the -# tests that involve on-disk sparse_xarrays we need to limit the -# maximum length of the queue. Figure out how many file descriptors -# we can let the test program open at once. -OPEN_MAX=`getconf OPEN_MAX 2>/dev/null` -case $OPEN_MAX in - [0-9]*) - # Divide by 2 because some fds are used by other code. - queue_limit=`expr $OPEN_MAX / 2` - ;; - undefined) - # Assume that any system with a dynamic fd limit has a large limit. - queue_limit=500 - ;; - *) - case `uname -m 2>/dev/null` in - CYGWIN*) - # Cygwin claims a 256-fd limit as OPEN_MAX in . - queue_limit=128 - ;; - MINGW*) - # The following email claims that Mingw should have a - # 2048-fd limit: - # http://www.mail-archive.com/squid-users@squid-cache.org/msg35249.html - queue_limit=1024 - ;; - *) - # This seems fairly conservative these days. - queue_limit=50 - ;; - esac - ;; -esac - -# Test completely in-memory sparse_xarray. --values=3 would be a -# slightly better test but takes much longer. -$RUN_TEST --columns=3 --max-rows=3 --max-memory-rows=3 --values=2 - -# Test on-disk sparse_xarrays. -for max_memory_rows in 0 1 2; do - $RUN_TEST --columns=2 --max-rows=3 --max-memory-rows=$max_memory_rows --values=2 --queue-limit=$queue_limit -done - -# Test copying back and forth between a pair of sparse_xarrays in -# memory. -$RUN_TEST --columns=2 --max-rows=2 --max-memory-rows=2 --values=2 --xarrays=2 --no-write-rows --no-copy-columns - -# Test copying back and forth between a pair of sparse_xarrays on -# disk. These parameters are ridiculously low, but it's necessary -# unless we want the tests to take a very long time. -for max_memory_rows in 0 1; do - $RUN_TEST --columns=1 --max-rows=2 --max-memory-rows=$max_memory_rows --values=2 --xarrays=2 --queue-limit=`expr $queue_limit / 2` --no-write-rows --no-copy-columns -done -- 2.30.2