File: testphp.awk

package info (click to toggle)
php3 3%3A3.0.18-0potato1.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 17,736 kB
  • ctags: 11,198
  • sloc: ansic: 108,120; sh: 2,512; php: 2,024; yacc: 1,887; makefile: 1,038; perl: 537; pascal: 238; awk: 90; cpp: 28; sql: 11
file content (90 lines) | stat: -rw-r--r-- 1,845 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
BEGIN		{
				file=0;
				expect=0;
				get=0;
				post=0;
			}
/--TEST--/	{
				file=0;
				expect=0;
				get=0;
				post=0;
				testcase=1;
				getline;
			}
/--POST--/	{
				file=0;
				expect=0;
				get=0;
				post=1;
				testcase=0;
				getline;
			}
/--GET--/	{
				get=1;
				post=0;
				file=0;
				expect=0;
				testcase=0;
				getline;
			}
/--FILE--/	{
				file=1;
				expect=0;
				post=0;
				get=0;
				testcase=0;
				getline;
			}
/--EXPECT--/{
				expect=1;
				post=0;
				get=0;
				file=0;
				testcase=0;
				getline;
			}
			{
				if(file) {
					if(file==1) {
						file=2;
						print $0 >"php.in";
					} else {
						print $0 >>"php.in";
					}
				} else if(expect) {
					if(expect==1) {
						expect=2;
						print $0 >"php.out";
					} else {
						print $0 >>"php.out";
					}
				} else if(testcase) {
					if(expect==1) {
						expect=2;
						printf $0 >"php.desc";
					} else {
						printf $0 >>"php.desc";
					}
				} else if(post) {
					post=0;
					Post=$0;
				} else if(get) {
					get=0;
					Get=$0;
				}
			}
END			{
				p = "REQUEST_METHOD=POST CONTENT_TYPE=application/x-www-form-urlencoded PHP_TEST=1 REDIRECT_STATUS=1 PATH_TRANSLATED=./php.in CONTENT_LENGTH";
				if(length(Post) && length(Get)) {
					cmd = sprintf("echo %s | (%s=%d QUERY_STRING=%s SCRIPT_FILENAME=./php.in ../php -q -c.) >php.test", Post,p,length(Post),Get);
				} else if(length(Post) && !length(Get)) {
					cmd = sprintf("echo %s | (%s=%d SCRIPT_FILENAME=./php.in ../php -q -c.) >php.test",Post,p,length(Post));
				} else if(!length(Post) && length(Get)) {
					cmd = sprintf("(QUERY_STRING=%s SCRIPT_FILENAME=./php.in PHP_TEST=1 REDIRECT_STATUS=1 PATH_TRANSLATED=./php.in ../php -q -c.) >php.test",Get);
				} else {
					cmd = "../php -q -c. ./php.in >php.test";
				}
				print "cat php.desc;\n";
				print cmd;
			}