annotate scripts/test/split.test @ 952:ce0519f6457c

Add timeout, factoring out common code from sleep.
author Rob Landley <rob@landley.net>
date Wed, 17 Jul 2013 17:22:46 -0500
parents 7f83d1bfcd9f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
928
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/bin/bash
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 #testing "name" "command" "result" "infile" "stdin"
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 testing "split" "seq 1 12345 | split && ls xa[a-z] | wc -l" "13\n" "" ""
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 rm xa[a-z]
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
9
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
10 testing "split -" "seq 1 12345 | split - && ls xa[a-z] | wc -l" "13\n" "" ""
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 rm xa[a-z]
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
12
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 seq 1 12345 > file
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 testing "split file" "split file && ls xa[a-z] | wc -l" "13\n" "" ""
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 rm xa[a-z]
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
16
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 testing "split -l" "split file -l 10k && wc -l xab" "2105 xab\n" "" ""
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 rm xa[ab]
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
19
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 testing "split suffix exhaustion" \
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 "split file -l 10 -a 1 walrus 2>/dev/null || ls walrus* | wc -l" "26\n" "" ""
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 rm walrus*
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
23
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 testing "split bytes" \
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 "toybox seq 1 20000 | split -b 100 -a 3 - whang && ls whang* | wc -l && wc -c whangbpw" "1089\n94 whangbpw\n" "" ""
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
26
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
27 testing "split reassembly" \
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 'diff -u <(ls whang* | sort | xargs cat) <(seq 1 20000) && echo yes' \
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 "yes\n" "" ""
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
30
7f83d1bfcd9f Test cases for split.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 rm file whang*