summaryrefslogtreecommitdiffstats
path: root/src/tests/hellotest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/hellotest.c')
-rw-r--r--src/tests/hellotest.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tests/hellotest.c b/src/tests/hellotest.c
new file mode 100644
index 000000000..e38856ee8
--- /dev/null
+++ b/src/tests/hellotest.c
@@ -0,0 +1,41 @@
+#include <stdint.h>
+#include <string.h>
+#include <byteswap.h>
+#include <console.h>
+#include <vsprintf.h>
+#include <gpxe/async.h>
+#include <gpxe/hello.h>
+
+static void test_hello_callback ( char *data, size_t len ) {
+ unsigned int i;
+ char c;
+
+ for ( i = 0 ; i < len ; i++ ) {
+ c = data[i];
+ if ( c == '\r' ) {
+ /* Print nothing */
+ } else if ( ( c == '\n' ) || ( c >= 32 ) || ( c <= 126 ) ) {
+ putchar ( c );
+ } else {
+ putchar ( '.' );
+ }
+ }
+}
+
+void test_hello ( struct sockaddr_in *server, const char *message ) {
+ struct hello_request hello;
+ int rc;
+
+ printf ( "Saying \"%s\" to %s:%d\n", message,
+ inet_ntoa ( server->sin_addr ), ntohs ( server->sin_port ) );
+
+ memset ( &hello, 0, sizeof ( hello ) );
+ hello.tcp.sin = *server;
+ hello.message = message;
+ hello.callback = test_hello_callback;
+
+ rc = async_wait ( say_hello ( &hello ) );
+ if ( rc ) {
+ printf ( "HELLO fetch failed\n" );
+ }
+}