~sircmpwn/ctools

ref: 0e9f63c42367ef836a3dbe9369cb987558b0d9e3 ctools/test/cksum -rwxr-xr-x 808 bytes
0e9f63c4 — Christopher Vittal Add dirname 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
. "$HARNESS" cksum

should_handle_empty_stdin() (
	[ "$(cksum </dev/null)" = "4294967295 0" ]
)

should_handle_normal_stdin() (
	[ "$(echo hello world | cksum)" = "3733384285 12" ]
)

should_handle_empty_file() (
	[ "$(cksum </dev/null)" = "4294967295 0" ]
)

should_handle_largefile() (
	[ "$(largefile | cksum)" = "4033688160 12288" ]
)

should_handle_multifile() (
	largefile >"$TMPDIR"/largefile
	output=$(cksum /dev/null "$TMPDIR"/largefile)
	[ "$(echo "$output" | head -n1)" = "4033688160 12288 $TMPDIR/largefile" ]
	[ "$(echo "$output" | head -n1)" = "4294967295 0 /dev/null" ]
)

should_handle_ddash cksum /dev/null

runtests \
	should_handle_ddash \
	should_handle_empty_stdin \
	should_handle_normal_stdin \
	should_handle_empty_file \
	should_handle_largefile \
	should_handle_multifile