예제 #1
0
파일: test.py 프로젝트: millisetan/apue
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
"""
)
예제 #2
0
파일: test.py 프로젝트: millisetan/apue
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',))
예제 #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
""")
예제 #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,
)
예제 #5
0
파일: test.py 프로젝트: millisetan/apue
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
"""\
예제 #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
예제 #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', ))
예제 #8
0
파일: test.py 프로젝트: millisetan/apue
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
""")
예제 #9
0
파일: test.py 프로젝트: yf8848/apue-1
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)
""")
예제 #10
0
파일: test.py 프로젝트: yf8848/apue-1
% ./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.
)
예제 #11
0
from shell_doctest import test

test("""\
% {make} --no-print-directory clean all
...
% ./putenv_r
HELLO=world
""")
예제 #12
0
파일: test.py 프로젝트: millisetan/apue
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,
)
예제 #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,
)
예제 #14
0
파일: test.py 프로젝트: millisetan/apue
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,
)
예제 #15
0
from shell_doctest import test

test("""\
% {make} --no-print-directory clean all
...
% ./pr02-17
open_max: ...
""")
예제 #16
0
파일: test.py 프로젝트: millisetan/apue
% {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.
)
예제 #17
0
파일: test.py 프로젝트: millisetan/apue
from shell_doctest import test

test(
"""\
% {make} --no-print-directory clean all
...
% ./putenv_r
HELLO=world
"""
)
예제 #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
"""
)
예제 #19
0
파일: test.py 프로젝트: millisetan/apue
from shell_doctest import test

test(
"""\
% {make} --no-print-directory clean all
...
% ./pr02-17
open_max: ...
"""
)
예제 #20
0
파일: test.py 프로젝트: millisetan/apue
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',))
예제 #21
0
파일: test.py 프로젝트: yf8848/apue-1
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
""")
예제 #22
0
파일: test.py 프로젝트: millisetan/apue
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)
"""
)
예제 #23
0
파일: test.py 프로젝트: 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,
)
예제 #24
0
from shell_doctest import test

test("""\
% {make} --no-print-directory clean all
...
% sudo ./print_enc_pass
                root    $...
...
                  tn    $...
... password entries read
""")
예제 #25
0
파일: test.py 프로젝트: millisetan/apue
from shell_doctest import test

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