]>
Commit | Line | Data |
---|---|---|
b4285c71 RS |
1 | #!/bin/sh |
2 | ||
3 | test_description='check that the most basic functions work | |
4 | ||
5 | ||
6 | Verify wrappers and compatibility functions. | |
7 | ' | |
8 | ||
03267e86 | 9 | TEST_PASSES_SANITIZE_LEAK=true |
b4285c71 RS |
10 | . ./test-lib.sh |
11 | ||
12 | test_expect_success 'character classes (isspace, isalpha etc.)' ' | |
e4998944 | 13 | test-tool ctype |
b4285c71 RS |
14 | ' |
15 | ||
6cf6bb3e | 16 | test_expect_success 'mktemp to nonexistent directory prints filename' ' |
d9cc2c87 | 17 | test_must_fail test-tool mktemp doesnotexist/testXXXXXX 2>err && |
6cf6bb3e AE |
18 | grep "doesnotexist/test" err |
19 | ' | |
20 | ||
b3b8ceb4 | 21 | test_expect_success POSIXPERM,SANITY 'mktemp to unwritable directory prints filename' ' |
6cf6bb3e | 22 | mkdir cannotwrite && |
6cf6bb3e | 23 | test_when_finished "chmod +w cannotwrite" && |
03771425 | 24 | chmod -w cannotwrite && |
d9cc2c87 | 25 | test_must_fail test-tool mktemp cannotwrite/testXXXXXX 2>err && |
6cf6bb3e AE |
26 | grep "cannotwrite/test" err |
27 | ' | |
28 | ||
253b27f1 DW |
29 | test_expect_success 'git_mkstemps_mode does not fail if fd 0 is not open' ' |
30 | git commit --allow-empty -m message <&- | |
31 | ' | |
32 | ||
c9184159 RJ |
33 | test_expect_success 'check for a bug in the regex routines' ' |
34 | # if this test fails, re-build git with NO_REGEX=1 | |
9038531f | 35 | test-tool regex --bug |
c9184159 RJ |
36 | ' |
37 | ||
17e7dbbc JS |
38 | test_expect_success 'incomplete sideband messages are reassembled' ' |
39 | test-tool pkt-line send-split-sideband >split-sideband && | |
40 | test-tool pkt-line receive-sideband <split-sideband 2>err && | |
41 | grep "Hello, world" err | |
42 | ' | |
43 | ||
af22a63c JK |
44 | test_expect_success 'eof on sideband message is reported' ' |
45 | printf 1234 >input && | |
46 | test-tool pkt-line receive-sideband <input 2>err && | |
47 | test_i18ngrep "unexpected disconnect" err | |
48 | ' | |
49 | ||
50 | test_expect_success 'missing sideband designator is reported' ' | |
51 | printf 0004 >input && | |
52 | test-tool pkt-line receive-sideband <input 2>err && | |
53 | test_i18ngrep "missing sideband" err | |
54 | ' | |
55 | ||
eaa82f8e JX |
56 | test_expect_success 'unpack-sideband: --no-chomp-newline' ' |
57 | test_when_finished "rm -f expect-out expect-err" && | |
58 | test-tool pkt-line send-split-sideband >split-sideband && | |
59 | test-tool pkt-line unpack-sideband \ | |
60 | --no-chomp-newline <split-sideband >out 2>err && | |
61 | cat >expect-out <<-EOF && | |
62 | primary: regular output | |
63 | EOF | |
64 | cat >expect-err <<-EOF && | |
65 | Foo. | |
66 | Bar. | |
67 | Hello, world! | |
68 | EOF | |
69 | test_cmp expect-out out && | |
70 | test_cmp expect-err err | |
71 | ' | |
72 | ||
73 | test_expect_success 'unpack-sideband: --chomp-newline (default)' ' | |
74 | test_when_finished "rm -f expect-out expect-err" && | |
75 | test-tool pkt-line send-split-sideband >split-sideband && | |
76 | test-tool pkt-line unpack-sideband \ | |
77 | --chomp-newline <split-sideband >out 2>err && | |
78 | printf "primary: regular output" >expect-out && | |
79 | printf "Foo.Bar.Hello, world!" >expect-err && | |
80 | test_cmp expect-out out && | |
81 | test_cmp expect-err err | |
82 | ' | |
83 | ||
84 | test_expect_failure 'unpack-sideband: packet_reader_read() consumes sideband, no chomp payload' ' | |
85 | test_when_finished "rm -f expect-out expect-err" && | |
86 | test-tool pkt-line send-split-sideband >split-sideband && | |
87 | test-tool pkt-line unpack-sideband \ | |
88 | --reader-use-sideband \ | |
89 | --no-chomp-newline <split-sideband >out 2>err && | |
90 | cat >expect-out <<-EOF && | |
91 | primary: regular output | |
92 | EOF | |
93 | printf "remote: Foo. \n" >expect-err && | |
94 | printf "remote: Bar. \n" >>expect-err && | |
95 | printf "remote: Hello, world! \n" >>expect-err && | |
96 | test_cmp expect-out out && | |
97 | test_cmp expect-err err | |
98 | ' | |
99 | ||
100 | test_expect_failure 'unpack-sideband: packet_reader_read() consumes sideband, chomp payload' ' | |
101 | test_when_finished "rm -f expect-out expect-err" && | |
102 | test-tool pkt-line send-split-sideband >split-sideband && | |
103 | test-tool pkt-line unpack-sideband \ | |
104 | --reader-use-sideband \ | |
105 | --chomp-newline <split-sideband >out 2>err && | |
106 | printf "primary: regular output" >expect-out && | |
107 | printf "remote: Foo. \n" >expect-err && | |
108 | printf "remote: Bar. \n" >>expect-err && | |
109 | printf "remote: Hello, world! \n" >>expect-err && | |
110 | test_cmp expect-out out && | |
111 | test_cmp expect-err err | |
112 | ' | |
113 | ||
b4285c71 | 114 | test_done |