OSDN Git Service

Merge remote-tracking branch 'toybox/master' into HEAD
[android-x86/external-toybox.git] / tests / touch.test
1 #!/bin/bash
2
3 [ -f testing.sh ] && . testing.sh
4
5 #testing "name" "command" "result" "infile" "stdin"
6
7 testing "touch" "touch walrus && [ -e walrus ] && echo yes" "yes\n" "" ""
8 testing "1 2 3" "touch one two three && rm one two three && echo yes" "yes\n" \
9   "" ""
10 testing "-c" "touch -c walrus && [ -e walrus ] && echo yes" "yes\n" "" ""
11 testing "-c missing" "touch -c warrus && [ ! -e warrus ] && echo yes" \
12   "yes\n" "" ""
13
14 testing "-t" \
15   "touch -t 201201231234 walrus && date -r walrus +%Y%m%d-%H%M%S.%N" \
16   "20120123-123400.000000000\n" "" ""
17
18 testing "-t seconds" \
19   "touch -t 201201231234.56 walrus && date -r walrus +%Y%m%d-%H%M%S.%N" \
20   "20120123-123456.000000000\n" "" ""
21
22 testing "-t nanoseconds" \
23   "touch -t 201201231234.56123456789 walrus && date -r walrus +%Y%m%d-%H%M%S.%N" \
24   "20120123-123456.123456789\n" "" ""
25
26 testing "-d" \
27   "touch -d 2009-02-13T23:31:30Z walrus && date -r walrus +%s" \
28   "1234567890\n" "" ""
29
30 testing "-d nanoseconds" \
31   "touch -d 2009-02-13T23:31:30.123456789Z walrus && date -r walrus +%s.%N" \
32   "1234567890.123456789\n" "" ""
33
34 testing "-r" \
35   "touch -r walrus walrus2 && date -r walrus2 +%s.%N" \
36    "1234567890.123456789\n" "" ""
37
38 #testing "-a"
39 #testing "-m"
40 #testing "-am"
41 #testing "-t"
42 rm walrus walrus2