Skip to content

Commit edf36be

Browse files
committed
renew code for picohttpd
1 parent 5d7a8f0 commit edf36be

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

examples/rootfs

examples/src/linux/picohttpd/Makefile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
all: server arm_server
1+
all: x64_server arm_server
22

33
clean:
44
@rm -rf *.o
5-
@rm -rf server
5+
@rm -rf x64_server
66
@rm -rf arm_server
7+
@rm -rf armeb_server
78

8-
server: main.o httpd.o
9-
gcc -o server $^
9+
x64_server: main.o httpd.o
10+
gcc -o x64_server $^
1011
@rm -rf *.o
1112

12-
main.o: main.c httpd.h
13-
gcc -c -o main.o main.c
13+
x64_main.o: main.c httpd.h
14+
gcc -c -o x64_main.o main.c
1415

15-
httpd.o: httpd.c httpd.h
16-
gcc -c -o httpd.o httpd.c
16+
x64_httpd.o: httpd.c httpd.h
17+
gcc -c -o x64_httpd.o httpd.c
1718

1819
arm_server: arm_main.o arm_httpd.o
1920
arm-linux-gnueabi-gcc-10 -o arm_server $^

examples/src/linux/picohttpd/main.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
#include "httpd.h"
22

3-
int main(int c, char** v, int argc, const char **argv)
3+
#define PORT_DEFAULT "12913"
4+
5+
int main(int argc, const char **argv)
46
{
5-
serve_forever("12913");
7+
const char *PORT;
8+
9+
if (argc < 2) {
10+
PORT = PORT_DEFAULT;
11+
} else {
12+
PORT = argv[1];
13+
}
14+
15+
fprintf(stderr, "port is %s.\n", PORT);
16+
17+
serve_forever(PORT);
618
return 0;
719
}
820

tests/test_elf_multithread.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def check_write(ql, write_fd, write_buf, write_count, *args, **kw):
352352
except:
353353
pass
354354

355-
ql = Qiling(["../examples/rootfs/armeb_linux/bin/armeb_udp_test","20009"], "../examples/rootfs/armeb_linux", multithread=True)
355+
ql = Qiling(["../examples/rootfs/armeb_linux/bin/armeb_udp_test","20010"], "../examples/rootfs/armeb_linux", multithread=True)
356356
ql.os.set_syscall("write", check_write, QL_INTERCEPT.ENTER)
357357
ql.run()
358358

@@ -362,7 +362,7 @@ def check_write(ql, write_fd, write_buf, write_count, *args, **kw):
362362

363363
def test_http_elf_linux_x8664(self):
364364
def picohttpd():
365-
ql = Qiling(["../examples/rootfs/x8664_linux/bin/picohttpd"], "../examples/rootfs/x8664_linux", multithread=True, verbose=QL_VERBOSE.DEBUG)
365+
ql = Qiling(["../examples/rootfs/x8664_linux/bin/picohttpd","12911"], "../examples/rootfs/x8664_linux", multithread=True, verbose=QL_VERBOSE.DEBUG)
366366
ql.run()
367367

368368

@@ -371,12 +371,12 @@ def picohttpd():
371371

372372
time.sleep(1)
373373

374-
f = os.popen("curl http://127.0.0.1:12913")
374+
f = os.popen("curl http://127.0.0.1:12911")
375375
self.assertEqual("httpd_test_successful", f.read())
376376

377377
def test_http_elf_linux_arm(self):
378378
def picohttpd():
379-
ql = Qiling(["../examples/rootfs/arm_linux/bin/picohttpd"], "../examples/rootfs/arm_linux", multithread=True, verbose=QL_VERBOSE.DEBUG)
379+
ql = Qiling(["../examples/rootfs/arm_linux/bin/picohttpd","12912"], "../examples/rootfs/arm_linux", multithread=True, verbose=QL_VERBOSE.DEBUG)
380380
ql.run()
381381

382382

@@ -385,7 +385,7 @@ def picohttpd():
385385

386386
time.sleep(1)
387387

388-
f = os.popen("curl http://127.0.0.1:12913")
388+
f = os.popen("curl http://127.0.0.1:12912")
389389
self.assertEqual("httpd_test_successful", f.read())
390390

391391
def test_http_elf_linux_armeb(self):

0 commit comments

Comments
 (0)