Add copyright and licence notices to files which lack them.
[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 AT_BANNER([sparse external arrays])
17
18 m4_divert_push([PREPARE_TESTS])
19 [sparse_xarray_queue_limit () {
20   # Each on-disk sparse_xarray eats up a file descriptor, so for the
21   # tests that involve on-disk sparse_xarrays we need to limit the
22   # maximum length of the queue.  Figure out how many file descriptors
23   # we can let the test program open at once.
24   OPEN_MAX=`getconf OPEN_MAX 2>/dev/null`
25   case $OPEN_MAX in
26     [0-9]*)
27       # Divide by 2 because some fds are used by other code.
28       queue_limit=`expr $OPEN_MAX / 2` 
29       ;;
30     undefined) 
31       # Assume that any system with a dynamic fd limit has a large limit.
32       queue_limit=500 
33       ;;
34     *)
35       case `uname -m 2>/dev/null` in
36         CYGWIN*)
37           # Cygwin claims a 256-fd limit as OPEN_MAX in <limits.h>.
38           queue_limit=128
39           ;;
40         MINGW*)
41           # The following email claims that Mingw should have a
42           # 2048-fd limit:
43           # http://www.mail-archive.com/squid-users@squid-cache.org/msg35249.html
44           queue_limit=1024
45           ;;
46         *)
47           # This seems fairly conservative these days.
48           queue_limit=50
49           ;;
50       esac
51       ;;
52   esac
53   echo "$queue_limit"
54 }]
55 m4_divert_pop([PREPARE_TESTS])
56
57 AT_SETUP([in-memory sparse_xarray])
58 dnl --values=3 would be a slightly better test but takes much longer.
59 AT_CHECK([sparse-xarray-test \
60             --verbosity=0 --queue-limit=`sparse_xarray_queue_limit` \
61             --columns=3 --max-rows=3 --max-memory-rows=3 --values=2],
62   [0], [ignore], [ignore])
63 AT_CLEANUP
64
65 m4_define([SPARSE_XARRAY_ON_DISK],
66   [AT_SETUP([on-disk sparse_xarray max-memory-rows=$1])
67    AT_CHECK([sparse-xarray-test \
68                --verbosity=0 --queue-limit=`sparse_xarray_queue_limit` \
69                --columns=2 --max-rows=3 --max-memory-rows=$1 --values=2],
70      [0], [ignore], [ignore])
71    AT_CLEANUP])
72 SPARSE_XARRAY_ON_DISK([0])
73 SPARSE_XARRAY_ON_DISK([1])
74 SPARSE_XARRAY_ON_DISK([2])
75
76 AT_SETUP([copying between in-memory sparse_xarrays])
77 AT_KEYWORDS([sparse_xarray])
78 AT_CHECK([sparse-xarray-test \
79             --verbosity=0 --queue-limit=`sparse_xarray_queue_limit` \
80             --columns=2 --max-rows=2 --max-memory-rows=2 --values=2 \
81             --xarrays=2 --no-write-rows --no-copy-columns],
82   [0], [ignore], [ignore])
83 AT_CLEANUP
84
85 m4_define([SPARSE_XARRAY_COPY_DISK],
86   [AT_SETUP([copying between on-disk sparse_xarrays max-memory-rows=$1])
87    AT_KEYWORDS([sparse_xarray])
88    limit=`sparse_xarray_queue_limit`
89    AT_CHECK([sparse-xarray-test \
90                --verbosity=0 --queue-limit=`expr $limit / 2` \
91                --columns=1 --max-rows=2 --max-memory-rows=$max_memory_rows \
92                --values=2 --xarrays=2 --no-write-rows --no-copy-columns],
93             [0], [ignore], [ignore])
94    AT_CLEANUP])
95 dnl These parameters are ridiculously low, but it's necessary
96 dnl unless we want the tests to take a very long time.
97 SPARSE_XARRAY_COPY_DISK([0])
98 SPARSE_XARRAY_COPY_DISK([1])