Skip to content

Commit

Permalink
automatic commit at releng box
Browse files Browse the repository at this point in the history
  • Loading branch information
mc36 committed Mar 25, 2022
1 parent 68de07a commit 014b104
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
4 changes: 4 additions & 0 deletions misc/native/c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ for fn in pcapInt pcap2pcap sender; do
compileFile $fn "" "-lpthread -lpcap" ""
done

for fn in ptyRun; do
compileFile $fn "" "-lutil" ""
done

for fn in mapInt rawInt tapInt bundle vlan hdlcInt stdLin ttyLin modem; do
compileFile $fn "" "-lpthread" ""
done
58 changes: 58 additions & 0 deletions misc/native/ptyRun.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <poll.h>
#include <pty.h>


void err(char*buf) {
printf("%s\n", buf);
exit(1);
}


int main(int argc, char **argv) {

if (argc < 1) err("using: pty <bin> [args]");

struct pollfd* fds = malloc(sizeof(struct pollfd)*2);
if (fds == NULL) err("error allocating memory");
int commSock = 0;
int childPid = forkpty(&commSock, NULL, NULL, NULL);
if (childPid == -1) err("error creating pty");
if (childPid == 0) {
printf("child started\n");
execvp(argv[1], &(argv[1]));
return 0;
}
printf("child %i created on %i\n", childPid, commSock);
fflush(stdout);

int i;
unsigned char buf[1024];
for (;;) {
fds[0].fd = commSock;
fds[0].events = POLLIN;
fds[0].revents = 0;
fds[1].fd = STDIN_FILENO;
fds[1].events = POLLIN;
fds[1].revents = 0;
if (poll(fds, 2, 100) < 0) err("error in poll");
if ((fds[0].revents&POLLIN) != 0) {
i = read(commSock, buf, sizeof(buf));
write(STDOUT_FILENO, buf, i);
}
if ((fds[1].revents&POLLIN) != 0) {
i = read(STDIN_FILENO, buf, sizeof(buf));
write(commSock, buf, i);
}
i = fds[0].revents|fds[1].revents;
if ((i & POLLERR) != 0) err("error on sockets");
if ((i & POLLHUP) != 0) break;
}

printf("\nchild stopped\n");
fflush(stdout);
sleep(1);
}
2 changes: 1 addition & 1 deletion src/rtr.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
url;file;result;test
-;-;-;freeRouter v22.3.25-cur, done by cs@nop.
-;-;-;2022-03-25 12:39:04, took 00:07:06, with 100 workers, on 2780 cases, 0 failed, 0 traces, 5 retries
-;-;-;2022-03-25 12:50:13, took 00:09:08, with 100 workers, on 2780 cases, 0 failed, 0 traces, 8 retries
-;-;-;./rtr.bin
http://sources.freertr.net/cfg/basic.tst;basic.tst;success;dummy test
http://sources.freertr.net/cfg/conn-amt01.tst;conn-amt01.tst;success;amt over ipv4
Expand Down
2 changes: 1 addition & 1 deletion src/rtr.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</style>
<title>tester</title></head><body>
release: freeRouter v22.3.25-cur, done by cs@nop.<br/>
tested: 2022-03-25 12:39:04, took 00:07:06, with 100 workers, on 2780 cases, 0 failed, 0 traces, 5 retries<br/>
tested: 2022-03-25 12:50:13, took 00:09:08, with 100 workers, on 2780 cases, 0 failed, 0 traces, 8 retries<br/>
jvm: ./rtr.bin<br/>
<br/>
<table><thead><tr><td><b>file</b></td><td><b>result</b></td><td><b>test</b></td></tr></thead><tbody>
Expand Down

0 comments on commit 014b104

Please sign in to comment.