Skip to content

Commit

Permalink
now compiles on FreeBSD also, and tests run too
Browse files Browse the repository at this point in the history
  • Loading branch information
juce committed May 17, 2017
1 parent fc8ad3f commit 37a3e8c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sockproc: sockproc.c
gcc -Wall -Werror -o sockproc sockproc.c
$(CC) -Wall -Werror -o sockproc sockproc.c

test: sockproc
./tests.sh 12345
Expand Down
1 change: 1 addition & 0 deletions sockproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <string.h>
Expand Down
16 changes: 8 additions & 8 deletions tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/sh -e
#
# Some unit-tests
# (require 'nc' to be installed)
Expand All @@ -11,21 +11,21 @@ pidfile=/tmp/sockproc-test.pid
echo "========================="

# simple commands
echo -e "uname -a\r\n0\r\n" | nc 127.0.0.1 $port
echo -e "id\r\n0\r\n" | nc 127.0.0.1 $port
echo "uname -a\r\n0\r\n" | nc 127.0.0.1 $port
echo "id\r\n0\r\n" | nc 127.0.0.1 $port

# commands with some input
echo -e "wc -l\r\n12\r\nline1\r\nline2" | nc 127.0.0.1 $port
echo -e "grep line\r\n20\r\nline1\r\nline2\r\nfoobar" | nc 127.0.0.1 $port
echo "wc -l\r\n12\r\nline1\r\nline2" | nc 127.0.0.1 $port
echo "grep line\r\n20\r\nline1\r\nline2\r\nfoobar" | nc 127.0.0.1 $port

# bad command.expecting non-empty error stream
echo -e "thisshouldfail\r\n0\r\n" | nc 127.0.0.1 $port
echo "thisshouldfail\r\n0\r\n" | nc 127.0.0.1 $port

# this should have data in both output and error streams
echo -e "echo hello output && echo hello error >&2\r\n0\r\n" | nc 127.0.0.1 $port
echo "echo hello output && echo hello error >&2\r\n0\r\n" | nc 127.0.0.1 $port

# long command line strings
echo -e "echo "\
echo "echo "\
"12345678901234567890123456789012345678901234567890"\
"12345678901234567890123456789012345678901234567890"\
"12345678901234567890123456789012345678901234567890"\
Expand Down

0 comments on commit 37a3e8c

Please # to comment.