]> arthur.barton.de Git - bup.git/blob - t/test-argv
test-restore-map-owner: accommodate python 3 and test there
[bup.git] / t / test-argv
1 #!/bin/sh
2 """": # -*-python-*-
3 bup_python="$(dirname "$0")/../cmd/bup-python" || exit $?
4 exec "$bup_python" "$0" ${1+"$@"}
5 """
6 # end of bup preamble
7
8 from __future__ import absolute_import, print_function
9
10 from os.path import abspath, dirname
11 from random import randint
12 from subprocess import check_output
13 from sys import stderr, stdout
14 import sys
15
16 script_home = abspath(dirname(sys.argv[0] or '.'))
17 sys.path[:0] = [abspath(script_home + '/../lib'), abspath(script_home + '/..')]
18
19 from wvtest import wvcheck, wvfail, wvmsg, wvpass, wvpasseq, wvpassne, wvstart
20
21 wvstart('command line arguments are not mangled')
22
23 def rand_bytes(n):
24     return bytes([randint(1, 255) for x in range(n)])
25
26 for trial in range(100):
27     cmd = [b't/echo-argv-bytes', rand_bytes(randint(1, 32))]
28     out = check_output(cmd)
29     wvpasseq(b'\0\n'.join(cmd) + b'\0\n', out)