Ejemplo n.º 1
0
from shell_doctest import test

test(
"""\
% {make} --no-print-directory clean all
...
% ./seeking
File contents (26 bytes): abcdefghijklmnopqrstuvwxyz
current_position: 0
Setting position in the middle of the file
current_position: 10
Writing 11 symbols
current_position: 37
File contents (37 bytes): abcdefghijklmnopqrstuvwxyzhello there
current_position: 37
"""
)
Ejemplo n.º 2
0
from shell_doctest import tests, test


test("""\
% {make} --no-print-directory clean all
...
% ./wait1
normal termination, exit status = 7
abnormal termination, signal number = 6...
abnormal termination, signal number = 8...
""", exclude=('DragonFly',))
Ejemplo n.º 3
0
from shell_doctest import test

test("""\
% {make} --no-print-directory clean all
...
% ./seeking
File contents (26 bytes): abcdefghijklmnopqrstuvwxyz
current_position: 0
Setting position in the middle of the file
current_position: 10
Writing 11 symbols
current_position: 37
File contents (37 bytes): abcdefghijklmnopqrstuvwxyzhello there
current_position: 37
""")
Ejemplo n.º 4
0
from shell_doctest import test

test(
    """\
% {make} --no-print-directory clean all
...
% ./filetype ../*
../4.3: regular
../4.7: regular
...
../broken: stat error: No such file or directory
../dir3: directory
../ex01-filetype: directory
../ex04-umask: directory
../ex06-holes: directory
../ex09: directory
../ex11-ftw: directory
../ex16-deep-tree: directory
...
../readdir: directory
../root: directory
""",
    debug=False,
)
Ejemplo n.º 5
0
from shell_doctest import tests, test


# Rebuild.
test("""\
% {make} --no-print-directory clean all
...
""")


##
# Setuid under root should set all three uids.
test("""\
% sudo ./check_setuid 1
Real user ID: 0 (root)
Effective user ID: 0 (root)
Saved user ID: 0 (root)

Calling setuid(1)

Real user ID: 1 (daemon)
Effective user ID: 1 (daemon)
Saved user ID: 1 (daemon)
""")


##
# Setuid on sunos and linux
tests([
# Make file setuid daemon
"""\
Ejemplo n.º 6
0
from shell_doctest import tests, test

# Rebuild.
test("""\
% {make} --no-print-directory clean all
...
""")

##
# Setuid under root should set all three uids.
test("""\
% sudo ./check_setuid 1
Real user ID: 0 (root)
Effective user ID: 0 (root)
Saved user ID: 0 (root)

Calling setuid(1)

Real user ID: 1 (daemon)
Effective user ID: 1 (daemon)
Saved user ID: 1 (daemon)
""")

##
# Setuid on sunos and linux
tests(
    [
        # Make file setuid daemon
        """\
% sudo chown daemon check_setuid
% sudo chmod u+s check_setuid
Ejemplo n.º 7
0
from shell_doctest import tests, test

test(
    """\
% {make} --no-print-directory clean all
...
% ./zombie
child pid: ...
Child status (first letter should be `Z'): Z...
""",
    # `ps' seems to be broken on DragonFly, ps -p doesn't select zombie processes.
    # On FreeBSD it semi-broken -- it selects zombie processes if you pass `-a'
    # flag.
    exclude=('DragonFly', ))
Ejemplo n.º 8
0
from shell_doctest import tests, test


test("""\
% {make} --no-print-directory clean all
...
% ./opendir-close-on-exec
opendir("/"): FD_CLOEXEC is set
open("/"): FD_CLOEXEC is not set
""")
Ejemplo n.º 9
0
from shell_doctest import tests, test

test("""\
% {make} --no-print-directory clean all
...
% ./fd-passing
Parent: got fd: ..., seek: 0
Parent: seek after child changed it: 10 (should be 10)
Parent: seek after child changed it second time: 20 (should be 20)
""")
Ejemplo n.º 10
0
% ./check-holes file.nohole
""",
        # make-file-with-holes should create file with correct number & size of holes.
        """\
% ./make-file-with-holes file.hole
% ./check-holes file.hole
Hole from 0 to 131072
Hole from 262144 to 393216
""",
        # Check that ./copy-holes preserve holes.
        """\
% ./copy-holes file.hole file.hole.copy
% ./check-holes file.hole.copy
Hole from 0 to 131072
Hole from 262144 to 393216
% rm file.hole.copy
"""
    ],
    exclude=('DragonFly', )  # At least when using HAMMER fs.
)

test(
    # Check that cp doesn't preserve holes.
    """\
% cp file.hole file.hole.cp_copy
% ./check-holes file.hole.cp_copy
% rm file.hole.cp_copy
""",
    exclude=('Linux', 'DragonFly')  # cp on linux actually does.
)
Ejemplo n.º 11
0
from shell_doctest import test

test("""\
% {make} --no-print-directory clean all
...
% ./putenv_r
HELLO=world
""")
Ejemplo n.º 12
0
from shell_doctest import test

test(
"""\
% rm -f foo bar
% {make} --no-print-directory clean all
...
% ./mydup2 mydup2.c | sed 's/\x1b\[[0-9;]*m//g'  # sed is for stripping colors.
>> Checking fd#3
current_position: 1651
FD_CLOEXEC: 0
File status: O_RDONLY
...
>> Checking fd#42
current_position: 1651
FD_CLOEXEC: 0
File status: O_RDONLY
...
""", debug=False,
)
Ejemplo n.º 13
0
from shell_doctest import test

test(
"""\
% rm -f foo bar
% {make} --no-print-directory clean all
...
% ./test-umask
% ls -l foo bar
-rw------- 1 tn ... bar
-rw-rw-rw- 1 tn ... foo
""", debug=False,
)
Ejemplo n.º 14
0
from shell_doctest import test

test(
"""\
% {make} --no-print-directory clean all
...
% ./filetype ../*
../4.3: regular
../4.7: regular
...
../broken: stat error: No such file or directory
../dir3: directory
../ex01-filetype: directory
../ex04-umask: directory
../ex06-holes: directory
../ex09: directory
../ex11-ftw: directory
../ex16-deep-tree: directory
...
../readdir: directory
../root: directory
""", debug=False,
)
Ejemplo n.º 15
0
from shell_doctest import test

test("""\
% {make} --no-print-directory clean all
...
% ./pr02-17
open_max: ...
""")
Ejemplo n.º 16
0
% {make} --no-print-directory clean all
...
% ./check-holes file.nohole
""",
# make-file-with-holes should create file with correct number & size of holes.
"""\
% ./make-file-with-holes file.hole
% ./check-holes file.hole
Hole from 0 to 131072
Hole from 262144 to 393216
""",
# Check that ./copy-holes preserve holes.
"""\
% ./copy-holes file.hole file.hole.copy
% ./check-holes file.hole.copy
Hole from 0 to 131072
Hole from 262144 to 393216
% rm file.hole.copy
"""
], exclude=('DragonFly',) # At least when using HAMMER fs.
)

test(
# Check that cp doesn't preserve holes.
"""\
% cp file.hole file.hole.cp_copy
% ./check-holes file.hole.cp_copy
% rm file.hole.cp_copy
""", exclude=('Linux', 'DragonFly')  # cp on linux actually does.
)
Ejemplo n.º 17
0
from shell_doctest import test

test(
"""\
% {make} --no-print-directory clean all
...
% ./putenv_r
HELLO=world
"""
)
Ejemplo n.º 18
0
from shell_doctest import tests, test

test(
"""\
% {make} --no-print-directory clean all
...
% rm -f output.ftw output.apue-ftw
% touch output.ftw output.apue-ftw
% sudo ./ftw /usr >| output.ftw
% sudo ./apue-ftw /usr >| output.apue-ftw
% # Sometimes outputs differ the first time the test run.
% diff output.ftw output.apue-ftw
% rm output.ftw output.apue-ftw
"""
)
Ejemplo n.º 19
0
from shell_doctest import test

test(
"""\
% {make} --no-print-directory clean all
...
% ./pr02-17
open_max: ...
"""
)
Ejemplo n.º 20
0
from shell_doctest import tests, test


test("""\
% {make} --no-print-directory clean all
...
% ./zombie
child pid: ...
Child status (first letter should be `Z'): Z...
""",
# `ps' seems to be broken on DragonFly, ps -p doesn't select zombie processes.
# On FreeBSD it semi-broken -- it selects zombie processes if you pass `-a'
# flag.
exclude=('DragonFly',))
Ejemplo n.º 21
0
from shell_doctest import tests, test

test("""\
% {make} --no-print-directory clean all
...
% ./opendir-close-on-exec
opendir("/"): FD_CLOEXEC is set
open("/"): FD_CLOEXEC is not set
""")
Ejemplo n.º 22
0
from shell_doctest import tests, test

test(
"""\
% {make} --no-print-directory clean all
...
% ./fd-passing
Parent: got fd: ..., seek: 0
Parent: seek after child changed it: 10 (should be 10)
Parent: seek after child changed it second time: 20 (should be 20)
"""
)
Ejemplo n.º 23
0
Archivo: test.py Proyecto: x746e/apue
from shell_doctest import test

test(
    """\
% rm -f foo bar
% {make} --no-print-directory clean all
...
% ./test-umask
% ls -l foo bar
-rw------- 1 tn ... bar
-rw-rw-rw- 1 tn ... foo
""",
    debug=False,
)
Ejemplo n.º 24
0
from shell_doctest import test

test("""\
% {make} --no-print-directory clean all
...
% sudo ./print_enc_pass
                root    $...
...
                  tn    $...
... password entries read
""")
Ejemplo n.º 25
0
from shell_doctest import test

test(
"""\
% {make} --no-print-directory clean all
...
% sudo ./print_enc_pass
                root    $...
...
                  tn    $...
... password entries read
"""
)