d1c95bfcbeea591e9374aec321384e50e87640ce
[tests.git] / qaapi / qa / tests / node / pf2test.pl
1 #!/usr/bin/perl
2
3 $netflow_slice="pl_netflow";
4
5 print "Warning! This test runs only once. I.e., it will usually not run twice in succession till syslog sees some new activitt\n";
6 print "Preparing...";
7
8
9 system("cp /var/log/messages /tmp/pf2_test");
10
11 # ping magic IP address
12 print "Sending out packet...\n";
13 system("su -c \"ping -I eth0 -c 1 10.0.0.8\" $netflow_slice -"); 
14
15 print "Waiting for flow to appear...\n";
16 sleep(10);
17
18 open PIP,"|/usr/bin/diff -u /tmp/pf2_test /var/log/messages";
19
20 while (<PIP>) {
21         if (/Received test flow to corewars.org from slice ([0-9]+)/) {
22                 $xid = int($1);
23                 print "Slice id: $xid\n";
24         $success=1;
25                 ($xid==0 || $xid==-1) && die("Slice id incorrect");
26         }
27 }
28
29 if ($success) {
30         print "[SUCCESS]";
31 }
32 else {
33         print "[FAILED]";
34 }
35
36
37 close PIP;
38