annotate scripts/test/cksum.test @ 890:c7e7b159568d

The host sort on many distros behaves stupidly, and sorts stuff in non-ascii order by default. Make it stop.
author Rob Landley <rob@landley.net>
date Mon, 29 Apr 2013 16:00:40 -0500
parents fa3293dda216
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
448
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
1 #!/bin/bash
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
2
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
3 [ -f testing.sh ] && . testing.sh
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
4
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
5
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
6 #testing "name" "command" "result" "infile" "stdin"
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
7
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
8 # Default behavior on stdin and on files.
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
9 testing "cksum on stdin" "echo -n hello | cksum" "3287646509 5\n" "" ""
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
10 echo -n "hello" > tmpfile
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
11 testing "cksum on file" "cksum tmpfile" "3287646509 5 tmpfile\n" "" ""
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
12 rm -f tmpfile
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
13 touch one two
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
14 testing "cksum on multiple files" "cksum one two" "4294967295 0 one\n4294967295 0 two\n" "" ""
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
15 rm -f one two
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
16
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
17 # Check the length suppression, both calculate the CRC on 'abc' but the second
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
18 # option has length suppression on and has the length concatenated to 'abc'.
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
19 testing "cksum on abc including length" "echo -n 'abc' | cksum" "1219131554 3\n" "" ""
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
20 testing "cksum on abc excluding length" "echo -ne 'abc\x3' | cksum -N" "1219131554 4\n" "" ""
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
21
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
22 # cksum on no contents gives 0xffffffff (=4294967295)
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
23 testing "cksum on no data post-inversion" "echo -n "" | cksum" "4294967295 0\n" "" ""
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
24 # If we do preinversion we will then get 0.
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
25 testing "cksum on no data pre+post-inversion" "echo -n "" | cksum -P" "0 0\n" "" ""
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
26 # If we skip the post-inversion we also get 0
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
27 testing "cksum on no data no inversion" "echo -n "" | cksum -I" "0 0\n" "" ""
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
28 # Two wrongs make a right.
fa3293dda216 Add tests for cksum
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
29 testing "cksum on no data pre-inversion" "echo -n "" | cksum -PI" "4294967295 0\n" "" ""