Skip to content

Commit

Permalink
t/file_malloc: Add.
Browse files Browse the repository at this point in the history
  • Loading branch information
rudis committed Feb 10, 2012
1 parent 50b8630 commit 880c483
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ The test files should be named according to the following convention:
* cmd_*: For each command (see libr/core/cmd.c).
* feat_*: For features not tied to a single command, like grep or
redirection.
* file_*: For each supported file format.

License
-------
Expand Down
64 changes: 64 additions & 0 deletions t/file_malloc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh

# GPL 3+ - Copyright (C) 2011-2012 pancake, Edd Barrett, Simon Ruderich

. ../tests.sh

## malloc:// "file"

# Normal request.
NAME='malloc://'
FILE=malloc://1024
ARGS=
CMDS='
i
px
'
EXPECT='file 1024
fd 42
size 0x400
mode r--
block 0x40
uri malloc://1024
offset 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF
0x00000000 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x00000010 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x00000020 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x00000030 0000 0000 0000 0000 0000 0000 0000 0000 ................'
# fd changes in each test, replace it with 42.
FILTER='sed "s/^fd\t[0-9][0-9]*/fd\t42/"'
run_test

# Small request.
NAME='malloc://'
FILE=malloc://1
ARGS=
CMDS='
i
px
'
EXPECT='file 1
fd 42
size 0x1
mode r--
block 0x40
uri malloc://1
offset 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF
0x00000000 00ff ffff ffff ffff ffff ffff ffff ffff ................
0x00000010 ffff ffff ffff ffff ffff ffff ffff ffff ................
0x00000020 ffff ffff ffff ffff ffff ffff ffff ffff ................
0x00000030 ffff ffff ffff ffff ffff ffff ffff ffff ................'
# fd changes in each test, replace it with 42.
FILTER='sed "s/^fd\t[0-9][0-9]*/fd\t42/"'
run_test

# No memory requested.
NAME='malloc://'
FILE=malloc://
ARGS=
CMDS='
'
EXPECT='Cannot allocate () 0 bytes
Cannot open file.'
EXITCODE=1
run_test

0 comments on commit 880c483

Please sign in to comment.