Fix FileIn cmds losing synch if both ends send cancel messages (RHBZ#576879).
[libguestfs.git] / regressions / rhbz557655.sh
1 #!/bin/bash -
2 # libguestfs
3 # Copyright (C) 2009 Red Hat Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 # Regression test for:
20 # https://bugzilla.redhat.com/show_bug.cgi?id=557655
21 # "guestfish number parsing should not use atoi, should support '0...' for octal and '0x...' for hexadecimal"
22
23 set -e
24 rm -f test.out test.err
25 export LANG=C
26
27 ../fish/guestfish >> test.out 2>> test.err <<EOF
28 # set-memsize is just a convenient non-daemon function that
29 # takes a single integer argument.
30 set-memsize 0
31 get-memsize
32 set-memsize 0x10
33 get-memsize
34 set-memsize 010
35 get-memsize
36 set-memsize -1073741824
37 get-memsize
38 set-memsize 1073741823
39 get-memsize
40
41 # the following should all provoke error messages:
42 -set-memsize -9000000000000000
43 -set-memsize 9000000000000000
44 -set-memsize 0x900000000000
45 -set-memsize 07777770000000000000
46 -set-memsize ABC
47 -set-memsize 09
48 -set-memsize 123K
49 -set-memsize 123L
50 EOF
51
52 ../fish/guestfish -N fs -m /dev/sda1 >> test.out 2>> test.err <<EOF
53 touch /test
54
55 # truncate-size takes an Int64 argument
56 truncate-size /test 1234
57 filesize /test
58 truncate-size /test 0x4d2
59 filesize /test
60 truncate-size /test 02322
61 filesize /test
62
63 # should parse OK, but underlying filesystem will reject it:
64 -truncate-size /test 0x7fffffffffffffff
65
66 # larger than 64 bits, should be an error:
67 -truncate-size /test 0x10000000000000000
68
69 # these should all provoke parse errors:
70 -truncate-size /test ABC
71 -truncate-size /test 09
72 -truncate-size /test 123K
73 -truncate-size /test 123L
74 EOF
75
76 # If we are running with debugging enabled (or even if not), then
77 # other messages and warnings can end up in the test.err (stderr) log.
78 # Thus filter out only lines we expect.  'proc 200' is the procedure
79 # number of truncate_size.
80 mv test.err test.err~
81 grep -E 'set[-_]memsize|truncate[-_]size' test.err~ |
82   grep -Ev 'proc 200' > test.err
83 rm test.err~
84
85 diff -u test.out rhbz557655-expected.stdout
86 diff -u test.err rhbz557655-expected.stderr
87 rm test.out test.err test1.img