diff --git a/repos/libports/run/test-ping_client.run b/repos/libports/run/test-ping_client.run deleted file mode 100644 index e159c01cfe..0000000000 --- a/repos/libports/run/test-ping_client.run +++ /dev/null @@ -1,176 +0,0 @@ -# -# \brief Test ping -# \author Josef Soentgen -# \date 2013-01-06 -# - -# -# Build -# - -if {[have_spec odroid_xu]} { - puts "Run script does not support this platform." - exit 0 -} - -set build_components { - core init - drivers/timer drivers/nic - test/lwip/pingpong/client -} - -lappend_if [expr [have_spec omap4] || [have_spec arndale]] build_components drivers/usb -lappend_if [have_spec gpio] build_components drivers/gpio - -proc gpio_drv { } { if {[have_spec rpi] && [have_spec hw]} { return hw_gpio_drv } - if {[have_spec rpi] && [have_spec foc]} { return foc_gpio_drv } - return gpio_drv } - -source ${genode_dir}/repos/base/run/platform_drv.inc -append_platform_drv_build_components - -build $build_components - -create_boot_directory - -# -# Generate config -# - -set config { - - - - - - - - - - - - - - - - - - } - -append_if [have_spec gpio] config " - - - - - " - -append_if [expr [have_spec omap4] || [have_spec arndale]] config { - - - - - - - - - } - -append_if [expr ![have_spec omap4] && ![have_spec arndale]] config { - - - - } - -append_platform_drv_config - -# establish serial connection with the server system -spawn picocom -b 115200 /dev/ttyUSB0 -set server_spawn_id $spawn_id -set timeout -1 -expect -i $server_spawn_id "Terminal ready" - -# get IP address from server -expect { - -i $server_spawn_id - -re "got IP address (.*)\033.*\n" { set ip_addr $expect_out(1,string) } -} -puts "got server IP address: $ip_addr" - -append config { - - - - - - - - - - - } -append config " - " -append config { - - - - - } - -append config { - -} - -install_config $config - -# -# Boot modules -# - -# generic modules -set boot_modules { - core init timer - ld.lib.so libc.lib.so vfs.lib.so lwip_legacy.lib.so posix.lib.so - test-ping_client_libc_lwip -} - -# platform-specific modules -lappend_if [expr [have_spec omap4] || [have_spec arndale]] boot_modules usb_drv -lappend_if [expr ![have_spec omap4] && ![have_spec arndale]] boot_modules nic_drv -lappend_if [have_spec gpio] boot_modules [gpio_drv] - -append_platform_drv_boot_modules - -build_boot_image $boot_modules - -# -# Execute test case -# - -# qemu config -append qemu_args " -nographic " - -append_if [have_spec x86] qemu_args " -net nic,model=e1000 " -append_if [have_spec lan9118] qemu_args " -net nic,model=lan9118 " - -append qemu_args " -net user " - -expect -i $server_spawn_id "wait..." - -run_genode_until {Sucessfully connected to server.} 60 - -expect -i $server_spawn_id "client 3 connected..." - -set time_start [clock milliseconds] - -set timeout -1 -expect { - -i $server_spawn_id - -re "received .*\n" { } -} - -set time_end [clock milliseconds] - -puts "\nTest succeeded in [expr $time_end - $time_start] milliseconds." - -# vi: set ft=tcl : diff --git a/repos/libports/run/test-ping_server.run b/repos/libports/run/test-ping_server.run deleted file mode 100644 index fe3eb66f50..0000000000 --- a/repos/libports/run/test-ping_server.run +++ /dev/null @@ -1,134 +0,0 @@ -# -# \brief Test pong -# \author Josef Soentgen -# \date 2013-01-06 -# - -# -# Build -# - -if {[have_spec odroid_xu]} { - puts "Run script does not support this platform." - exit 0 -} - -set build_components { - core init - drivers/timer drivers/nic - test/lwip/pingpong/server -} - -lappend_if [expr [have_spec omap4] || [have_spec arndale]] build_components drivers/usb -lappend_if [have_spec gpio] build_components drivers/gpio - -proc gpio_drv { } { if {[have_spec rpi] && [have_spec hw]} { return hw_gpio_drv } - if {[have_spec rpi] && [have_spec foc]} { return foc_gpio_drv } - return gpio_drv } - -source ${genode_dir}/repos/base/run/platform_drv.inc -append_platform_drv_build_components - -build $build_components - -create_boot_directory - -# -# Generate config -# - -set config { - - - - - - - - - - - - - - - - - - - - - - - - - - } - -append_if [have_spec gpio] config " - - - - - " - -append_if [expr [have_spec omap4] || [have_spec arndale]] config { - - - - - - - - - } - -append_if [expr ![have_spec omap4] && ![have_spec arndale]] config { - - - - } - -append_platform_drv_config - -append config { - -} - -install_config $config - -# -# Boot modules -# - -# generic modules -set boot_modules { - core init timer - ld.lib.so libc.lib.so vfs.lib.so lwip_legacy.lib.so posix.lib.so - test-ping_server_libc_lwip -} - -# platform-specific modules -lappend_if [expr [have_spec omap4] || [have_spec arndale]] boot_modules usb_drv -lappend_if [expr ![have_spec omap4] && ![have_spec arndale]] boot_modules nic_drv -lappend_if [have_spec gpio] boot_modules [gpio_drv] - -append_platform_drv_boot_modules - -build_boot_image $boot_modules - -# -# Execute test case -# - -# qemu config -append qemu_args " -nographic " - -append_if [have_spec x86] qemu_args " -net nic,model=e1000 " -append_if [have_spec lan9118] qemu_args " -net nic,model=lan9118 " - -append qemu_args " -net user " - -run_genode_until forever - -# vi: set ft=tcl : diff --git a/repos/libports/src/test/lwip/pingpong/README b/repos/libports/src/test/lwip/pingpong/README deleted file mode 100644 index f87ae0c8a7..0000000000 --- a/repos/libports/src/test/lwip/pingpong/README +++ /dev/null @@ -1,13 +0,0 @@ -Pingpong is a simple test where a client sends ping packets with different -sizes to a server. The client has to specify the serverip in its config -as well as the start and end of the ping packet sizes in bytes. - -! -! -! -! -! -! - -If verbose is set 1 the client and the server will print the id and the -size of each packet (packet header + payload size). diff --git a/repos/libports/src/test/lwip/pingpong/client/libc_lwip/target.mk b/repos/libports/src/test/lwip/pingpong/client/libc_lwip/target.mk deleted file mode 100644 index 0c739455f8..0000000000 --- a/repos/libports/src/test/lwip/pingpong/client/libc_lwip/target.mk +++ /dev/null @@ -1,8 +0,0 @@ -TARGET = test-ping_client_libc_lwip -LIBS = posix lwip_legacy libc_lwip_nic_dhcp -SRC_CC = main.cc pingpong.cc - -vpath main.cc $(PRG_DIR)/.. -vpath pingpong.cc $(PRG_DIR)/../.. - -CC_CXX_WARN_STRICT = diff --git a/repos/libports/src/test/lwip/pingpong/client/lwip/target.mk b/repos/libports/src/test/lwip/pingpong/client/lwip/target.mk deleted file mode 100644 index a39a01bd44..0000000000 --- a/repos/libports/src/test/lwip/pingpong/client/lwip/target.mk +++ /dev/null @@ -1,10 +0,0 @@ -TARGET = test-ping_client_lwip -LIBS = posix lwip_legacy -SRC_CC = main.cc pingpong.cc - -INC_DIR += $(REP_DIR)/src/lib/lwip/include - -vpath main.cc $(PRG_DIR)/.. -vpath pingpong.cc $(PRG_DIR)/../.. - -CC_CXX_WARN_STRICT = diff --git a/repos/libports/src/test/lwip/pingpong/client/main.cc b/repos/libports/src/test/lwip/pingpong/client/main.cc deleted file mode 100644 index e5a41614da..0000000000 --- a/repos/libports/src/test/lwip/pingpong/client/main.cc +++ /dev/null @@ -1,149 +0,0 @@ -/* - * \brief Ping-client - * \author Josef Soentgen - * \date 2013-01-24 - * - */ - -/* - * Copyright (C) 2013-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -/* libc includes */ -#include - -#include "../pingpong.h" - -unsigned int verbose; - -int -dial(const char *addr) -{ - int s; - struct sockaddr_in in_addr; - - printf("Create new socket...\n"); - s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (s == -1) { - printf("ERROR: Could not create socket!\n"); - return -1; - } - - printf("Connect to server %s:%d...\n", addr, Sport); - in_addr.sin_port = htons(Sport); - in_addr.sin_family = AF_INET; - in_addr.sin_addr.s_addr = inet_addr(addr); - if (connect(s, (struct sockaddr *)&in_addr, sizeof (in_addr)) == -1) { - printf("ERROR: Could not connect to server!\n"); - close(s); - return -1; - } - - printf("Sucessfully connected to server.\n"); - - return s; -} - -int -sendping(const char *addr, size_t dsize, size_t count) -{ - Packet p; - int s; - size_t i; - size_t n = 0; - - s = dial(addr); - if (s == -1) - return -1; - - p.h.type = Tping; - p.h.dsize = dsize; - p.d = (char *)malloc(p.h.dsize); - if (p.d == NULL) { - printf("ERROR: Out of memory!\n"); - return -1; - } - - printf("Trying to send %zd packets...\n", count); - for (i = 0; i < count; i++) { - forgepacket(&p, i + 1); - - n = sendpacket(s, &p); - if (n == 0) - break; - if (n != (sizeof (Packetheader) + p.h.dsize)) { - printf("ERROR: size mismatch: %ld != %lu\n", - (long)n, (long)(sizeof (Packetheader) + p.h.dsize)); - break; - } - - if (verbose) - printf("%u %ld\n", (unsigned)p.h.id, (long)n); - } - - close(s); - free(p.d); - - switch (n) { - case 0: - printf("Disconnect, sent packets: %zu\n", i); - return 0; - break; - default: - printf("Sucessfull, sent packets: %zu\n", i); - return 0; - break; - } - - /* never reached */ - return 0; -} - -int -main(int argc, char *argv[]) -{ - char serverip[16] = "0.0.0.0"; - unsigned int i; - unsigned int startsize, endsize; - unsigned int count; - - /* default settings */ - startsize = 1; - endsize = 32768; - count = 1024; - verbose = 0; - -#if 0 - Genode::Xml_node argv_node = Genode::config()->xml_node().sub_node("argv"); - try { - argv_node.attribute("serverip" ).value(serverip, sizeof(serverip)); - argv_node.attribute("startsize").value( &startsize ); - argv_node.attribute("endsize").value( &endsize ); - argv_node.attribute("verbose").value( &verbose ); - } catch(...) { } -#endif - - for (int i = 1; i < argc; i += 2) { - if (strcmp(argv[i], "-serverip") == 0) - strncpy(serverip, argv[i+1], sizeof(serverip)); - else if (strcmp(argv[i], "-startsize") == 0) - startsize = atoi(argv[i+1]); - else if (strcmp(argv[i], "-endsize") == 0) - endsize = atoi(argv[i+1]); - else if (strcmp(argv[i], "-count") == 0) - count = atoi(argv[i+1]); - } - - if ((endsize + sizeof (Packetheader)) > Databuf) { - printf("ERROR: endsize is greater than the servers' data buffer\n"); - return 1; - } - - for (i = startsize; i <= endsize; i <<= 1) - sendping(serverip, i, count); - - return 0; -} diff --git a/repos/libports/src/test/lwip/pingpong/pingpong.cc b/repos/libports/src/test/lwip/pingpong/pingpong.cc deleted file mode 100644 index 88c02a32ae..0000000000 --- a/repos/libports/src/test/lwip/pingpong/pingpong.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* - * \brief PingPong - * \author Josef Soentgen - * \date 2013-01-24 - * - */ - -/* - * Copyright (C) 2013-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -/* libc includes */ -#include - -#include "pingpong.h" - -void -forgepacket(Packet *p, uint32_t id) -{ - p->h.id = id; - p->d[p->h.dsize - 1] = (id % 128); -} - -int -checkpacket(size_t n, Packet *p) -{ - /* check size of received packet */ - if (n != (sizeof (Packetheader) + p->h.dsize)) { - printf("ERROR: packetsize mismatch!\n"); - return -1; - } - - /* check packet type */ - if (p->h.type != Tping) { - printf("ERROR: wrong packet type!\n"); - return -1; - } - - /* check payload */ - if (p->d[p->h.dsize - 1] != (char)(p->h.id % 128)) { - printf("ERROR: packet payload corrupt, expected: %d got: %d\n", (p->h.id % 128), - p->d[p->h.dsize - 1]); - return -1; - } - - return 0; -} - -size_t -sendpacket(int s, Packet *p) -{ - char *b; - ssize_t sent; - size_t nd, nh, dsize; - - /* send packet header */ - b = (char *)&p->h; - nh = 0; - while (nh < sizeof (Packetheader)) { - sent = send(s, b + nh, sizeof (Packetheader) - nh, 0); - switch (sent) { - case -1: - printf("ERROR: send(Packetheader) == -1\n"); - return nh; - break; - case 0: - printf("ERROR: send(Packetheader) == 0, connection closed\n"); - return nh; - break; - default: - nh += sent; - } - } - - /* sent packet data */ - b = (char *)p->d; - dsize = p->h.dsize; // save data length - nd = 0; - while (nd < dsize) { - sent = send(s, b + nd, dsize - nd, 0); - switch (sent) { - case -1: - printf("ERROR: send(data) == -1\n"); - return nd; - break; - case 0: - printf("ERROR: send(data) == 0, connection closed\n"); - return nd; - break; - default: - nd += sent; - } - } - - return nh + nd; -} - -size_t -recvpacket(int s, Packet *p, char *dbuf, size_t ldbuf) -{ - char *b; - ssize_t r; - size_t nd, nh, dsize; - - /* recv packet header */ - b = (char *)&p->h; - nh = 0; - while (nh < sizeof (Packetheader)) { - r = recv(s, b + nh, sizeof (Packetheader) - nh, 0); - switch (r) { - case -1: - printf("ERROR: recv(Packetheader) == -1\n"); - return nh; - break; - case 0: - /* disconnect */ - //printf("ERROR: recv(Packetheader) == 0, connection closed\n"); - return nh; - break; - default: - nh += r; - break; - } - } - - if (p->h.dsize > ldbuf) { - printf("ERROR: packet payload is too large for dbuf!\n"); - return -1; - } - - /* receive packet data */ - dsize = p->h.dsize; - nd = 0; - while (nd < dsize) { - r = recv(s, dbuf + nd, dsize - nd, 0); - switch (r) { - case -1: - printf("ERROR: recv(data) == -1\n"); - return nh + nd; - break; - case 0: - /* disconnect */ - printf("ERROR: recv(data) == 0, connection closed\n"); - return nh + nd; - break; - default: - nd += r; - break; - } - } - - return nh + nd; -} diff --git a/repos/libports/src/test/lwip/pingpong/pingpong.h b/repos/libports/src/test/lwip/pingpong/pingpong.h deleted file mode 100644 index c467145955..0000000000 --- a/repos/libports/src/test/lwip/pingpong/pingpong.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * \brief PingPong - * \author Josef Soentgen - * \date 2013-01-24 - * - */ - -/* - * Copyright (C) 2013-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#ifndef _PINGPONG_H_ -#define _PINGPONG_H_ - -/* libc includes */ -#include - -#ifdef LWIP_NATIVE -#include -#define accept(a,b,c) lwip_accept(a,b,c) -#define bind(a,b,c) lwip_bind(a,b,c) -#define close(s) lwip_close(s) -#define connect(a,b,c) lwip_connect(a,b,c) -#define listen(a,b) lwip_listen(a,b) -#define recv(a,b,c,d) lwip_recv(a,b,c,d) -#define select(a,b,c,d,e) lwip_select(a,b,c,d,e) -#define send(a,b,c,d) lwip_send(a,b,c,d) -#define socket(a,b,c) lwip_socket(a,b,c) -#else -/* libc includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -enum { - Databuf = 1024 * 1024, // data buffer for server - Numpackets = 1024, - Pdata = 16384, - Sport = 10000, - Tping = 1, - Tpong = 2 -}; - -typedef struct Packetheader Packetheader; -struct Packetheader -{ - uint32_t type; // packet type - uint32_t id; // packet id - uint32_t dsize; // data size -}; - -typedef struct Packet Packet; -struct Packet -{ - Packetheader h; - char *d; -}; - -void forgepacket(Packet *, uint32_t); -int checkpacket(size_t, Packet *); - -size_t sendpacket(int, Packet *); -size_t recvpacket(int, Packet *, char *, size_t); - -#endif /* _PINGPONG_H_ */ diff --git a/repos/libports/src/test/lwip/pingpong/server/libc_lwip/target.mk b/repos/libports/src/test/lwip/pingpong/server/libc_lwip/target.mk deleted file mode 100644 index 147ba75818..0000000000 --- a/repos/libports/src/test/lwip/pingpong/server/libc_lwip/target.mk +++ /dev/null @@ -1,8 +0,0 @@ -TARGET = test-ping_server_libc_lwip -LIBS = posix libc_lwip_nic_dhcp libc_lwip lwip_legacy -SRC_CC = main.cc pingpong.cc - -vpath main.cc $(PRG_DIR)/.. -vpath pingpong.cc $(PRG_DIR)/../.. - -CC_CXX_WARN_STRICT = diff --git a/repos/libports/src/test/lwip/pingpong/server/lwip/target.mk b/repos/libports/src/test/lwip/pingpong/server/lwip/target.mk deleted file mode 100644 index f976659a96..0000000000 --- a/repos/libports/src/test/lwip/pingpong/server/lwip/target.mk +++ /dev/null @@ -1,12 +0,0 @@ -TARGET = test-ping_server_lwip -LIBS = posix lwip_legacy -SRC_CC = main.cc pingpong.cc - -CC_OPT += -DLWIP_NATIVE - -INC_DIR += $(REP_DIR)/src/lib/lwip/include - -vpath main.cc $(PRG_DIR)/.. -vpath pingpong.cc $(PRG_DIR)/../.. - -CC_CXX_WARN_STRICT = diff --git a/repos/libports/src/test/lwip/pingpong/server/main.cc b/repos/libports/src/test/lwip/pingpong/server/main.cc deleted file mode 100644 index dcbf05ed95..0000000000 --- a/repos/libports/src/test/lwip/pingpong/server/main.cc +++ /dev/null @@ -1,158 +0,0 @@ -/* - * \brief Ping-server - * \author Josef Soentgen - * \date 2013-01-24 - * - */ - -/* - * Copyright (C) 2013-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -/* libc includes */ -#include - -#ifdef LWIP_NATIVE -#include -#include -#endif - -#include "../pingpong.h" - -unsigned int verbose; - -int -announce(const char *addr) -{ - int s; - struct sockaddr_in in_addr; - - printf("Create new socket...\n"); - s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (s == -1) { - printf("ERROR: Could not create socket!\n"); - return -1; - } - - printf("Bind socket to %d\n", Sport); - in_addr.sin_port = htons(Sport); - in_addr.sin_family = AF_INET; - in_addr.sin_addr.s_addr = inet_addr(addr); - if ( bind(s, (struct sockaddr *)&in_addr, sizeof (in_addr)) == -1) { - printf("ERROR: Could not bind!\n"); - close(s); - return -1; - } - - return s; -} - -int -recvping(const char *addr) -{ - int s, c; - - struct sockaddr caddr; - socklen_t lcaddr = sizeof (caddr); - - s = announce(addr); - if (s == -1) - return -1; - - printf("Listen on %s:%d...\n", addr, Sport); - if (listen(s, 5) == -1) { - printf("ERROR: Could not listen!\n"); - close(s); - return -1; - } - - while (1) { - Packet p; - int act; - size_t packets; - ssize_t packet_size = 0; - ssize_t n; - - printf("wait...\n"); - c = accept(s, &caddr, &lcaddr); - if (c == -1) { - printf("ERROR: Invalid socket from accept()!\n"); - continue; - } - printf("client %d connected...\n", c); - - p.d = (char *)malloc(Databuf); - if (p.d == NULL) { - printf("ERROR: Out of memeory!\n"); - close(c); - break; - } - - /* receive packets from client */ - act = 1; packets = 0; - while (act) { - - fd_set rfds; - FD_ZERO(&rfds); - FD_SET(c, &rfds); - - if (select(c + 1, &rfds, NULL, NULL, NULL) == -1) - printf("ERROR: select() == -1\n"); - - n = recvpacket(c, &p, p.d, Databuf); - switch (n) { - case 0: - /* disconnect */ - //printf("ERROR: disconnect\n"); - close(c); - act = 0; - break; - default: - /* check if packet is valid */ - if (checkpacket(n, &p)) { - act = 0; - } else { - packets++; - packet_size = n; - } - break; - } - - if (verbose) - printf("%u %zd\n", p.h.id, n); - } - printf("received %zu packets of size %zu\n", packets, packet_size); - - free(p.d); - } - - close(s); - - return 0; -} - -int -main(int argc, char *argv[]) -{ - char listenip[16] = "0.0.0.0"; - -#ifdef LWIP_NATIVE - enum { BUF_SIZE = Nic::Packet_allocator::DEFAULT_PACKET_SIZE * 128 }; - - lwip_tcpip_init(); - /* DHCP */ - if (lwip_nic_init(0, 0, 0, BUF_SIZE, BUF_SIZE)) { - printf("ERROR: We got no IP address!\n"); - return 1; - } -#endif - - verbose = 0; - - recvping(listenip); - - return 0; -}