Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6614 clevermous 1
; Just a test of cmdline.inc.
2
; Checks that parsing of some predefined command lines
3
; gives some predefined command arguments.
4
; Nothing to see here.
5
format PE console 4.0
6
entry start
7
 
8
include 'win32a.inc'
9
include '../../struct.inc'
10
include '../../proc32.inc'
11
 
12
start:
13
        stdcall run_test, empty_cmdline, empty_args
14
        stdcall run_test, spaces_tabs_cmdline, empty_args
15
        stdcall run_test, fancy_quotes_cmdline, fancy_quotes_args
16
        stdcall run_test, fancy_slashes_cmdline, fancy_slashes_args
17
        stdcall run_test, unmatched_quote_cmdline, unmatched_quote_args
18
        xor     eax, eax
19
        ret
20
 
21
proc run_test
22
        mov     esi, [esp+4]
23
        xor     edi, edi
24
        xor     edx, edx
25
        call    parse_cmdline
26
        mov     eax, [esp+8]
27
        cmp     ebx, [eax]
28
        jnz     .invalid_argc
29
        test    edx, edx
30
        jnz     .invalid_edx
31
        mov     eax, [esp+4]
32
@@:
33
        inc     eax
34
        cmp     byte [eax-1], 0
35
        jnz     @b
36
        cmp     esi, eax
37
        jnz     .invalid_esi
38
        mov     esi, [esp+4]
39
        mov     edi, data_area
40
        mov     edx, argv_area
41
        call    parse_cmdline
42
        mov     eax, [esp+4]
43
@@:
44
        inc     eax
45
        cmp     byte [eax-1], 0
46
        jnz     @b
47
        cmp     esi, eax
48
        jnz     .invalid_esi
49
        mov     eax, [esp+8]
50
        cmp     ebx, [eax]
51
        jnz     .invalid_argc
52
        lea     ecx, [argv_area+ebx*4]
53
        cmp     edx, ecx
54
        jnz     .invalid_edx
55
        lea     esi, [eax+4]
56
        mov     edi, data_area
57
        mov     edx, argv_area
58
        test    ebx, ebx
59
        jz      .args_done
60
.args_check:
61
        cmp     [edx], edi
62
        jnz     .invalid_argv
63
        add     edx, 4
64
@@:
65
        cmpsb
66
        jnz     .invalid_argv
67
        cmp     byte [esi-1], 0
68
        jnz     @b
69
        dec     ebx
70
        jnz     .args_check
71
.args_done:
72
        ret     8
73
.invalid_argc:
74
        mov     eax, 1
75
        int3
76
        jmp     $
77
.invalid_edx:
78
        mov     eax, 2
79
        int3
80
        jmp     $
81
.invalid_esi:
82
        mov     eax, 3
83
        int3
84
        jmp     $
85
.invalid_argv:
86
        mov     eax, 4
87
        int3
88
        jmp     $
89
endp
90
 
91
include 'cmdline.inc'
92
 
93
empty_cmdline   db      0
94
spaces_tabs_cmdline     db      '  ',9,' ',9,0
95
empty_args      dd      0
96
 
97
fancy_quotes_cmdline    db      'begin"quoted mode"end\ \"escaped" "quotes" "1\" "" """escaped quotes 2"""',0
98
fancy_quotes_args       dd      4
99
        db      'beginquoted modeend\',0
100
        db      '"escaped quotes 1"',0
101
        db      0
102
        db      '"escaped quotes 2"',0
103
 
104
fancy_slashes_cmdline   db      'arg\\" "1\\x "arg 2\\x" arg3\" arg4\\\"',9,'"arg 5\"" "arg6\\\"" "arg 7\\"',0
105
fancy_slashes_args      dd      7
106
        db      'arg\ 1\\x',0
107
        db      'arg 2\\x',0
108
        db      'arg3"',0
109
        db      'arg4\"',0
110
        db      'arg 5"',0
111
        db      'arg6\"',0
112
        db      'arg 7\',0
113
 
114
unmatched_quote_cmdline db      'some string"test',0
115
unmatched_quote_args    dd      2
116
        db      'some',0
117
        db      'stringtest',0
118
 
119
align 4
120
data_area       rb      1024
121
argv_area       rd      256