76f0c3362d46a6fe5995132754cd1a14ae509c1a
[pspp] / tests / libpspp / sparse-xarray-test.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl 
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl 
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 AT_BANNER([sparse external arrays])
18
19 m4_divert_push([PREPARE_TESTS])
20 [sparse_xarray_queue_limit () {
21   # Each on-disk sparse_xarray eats up a file descriptor, so for the
22   # tests that involve on-disk sparse_xarrays we need to limit the
23   # maximum length of the queue.  Figure out how many file descriptors
24   # we can let the test program open at once.
25   OPEN_MAX=`getconf OPEN_MAX 2>/dev/null`
26   case $OPEN_MAX in
27     [0-9]*)
28       # Divide by 2 because some fds are used by other code.
29       queue_limit=`expr $OPEN_MAX / 2` 
30       ;;
31     undefined) 
32       # Assume that any system with a dynamic fd limit has a large limit.
33       queue_limit=500 
34       ;;
35     *)
36       case `uname -m 2>/dev/null` in
37         CYGWIN*)
38           # Cygwin claims a 256-fd limit as OPEN_MAX in <limits.h>.
39           queue_limit=128
40           ;;
41         MINGW*)
42           # The following email claims that Mingw should have a
43           # 2048-fd limit:
44           # http://www.mail-archive.com/squid-users@squid-cache.org/msg35249.html
45           queue_limit=1024
46           ;;
47         *)
48           # This seems fairly conservative these days.
49           queue_limit=50
50           ;;
51       esac
52       ;;
53   esac
54   echo "$queue_limit"
55 }]
56 m4_divert_pop([PREPARE_TESTS])
57
58 AT_SETUP([in-memory sparse_xarray])
59 dnl --values=3 would be a slightly better test but takes much longer.
60 AT_CHECK([sparse-xarray-test \
61             --verbosity=0 --queue-limit=`sparse_xarray_queue_limit` \
62             --columns=3 --max-rows=3 --max-memory-rows=3 --values=2],
63   [0], [ignore], [ignore])
64 AT_CLEANUP
65
66 m4_define([SPARSE_XARRAY_ON_DISK],
67   [AT_SETUP([on-disk sparse_xarray max-memory-rows=$1])
68    AT_CHECK([sparse-xarray-test \
69                --verbosity=0 --queue-limit=`sparse_xarray_queue_limit` \
70                --columns=2 --max-rows=3 --max-memory-rows=$1 --values=2],
71      [0], [ignore], [ignore])
72    AT_CLEANUP])
73 SPARSE_XARRAY_ON_DISK([0])
74 SPARSE_XARRAY_ON_DISK([1])
75 SPARSE_XARRAY_ON_DISK([2])
76
77 AT_SETUP([copying between in-memory sparse_xarrays])
78 AT_KEYWORDS([sparse_xarray])
79 AT_CHECK([sparse-xarray-test \
80             --verbosity=0 --queue-limit=`sparse_xarray_queue_limit` \
81             --columns=2 --max-rows=2 --max-memory-rows=2 --values=2 \
82             --xarrays=2 --no-write-rows --no-copy-columns],
83   [0], [ignore], [ignore])
84 AT_CLEANUP
85
86 m4_define([SPARSE_XARRAY_COPY_DISK],
87   [AT_SETUP([copying between on-disk sparse_xarrays max-memory-rows=$1])
88    AT_KEYWORDS([sparse_xarray])
89    limit=`sparse_xarray_queue_limit`
90    AT_CHECK([sparse-xarray-test \
91                --verbosity=0 --queue-limit=`expr $limit / 2` \
92                --columns=1 --max-rows=2 --max-memory-rows=$max_memory_rows \
93                --values=2 --xarrays=2 --no-write-rows --no-copy-columns],
94             [0], [ignore], [ignore])
95    AT_CLEANUP])
96 dnl These parameters are ridiculously low, but it's necessary
97 dnl unless we want the tests to take a very long time.
98 SPARSE_XARRAY_COPY_DISK([0])
99 SPARSE_XARRAY_COPY_DISK([1])