source: branches/reconfiguration/modules/dspin_router/caba/test/synthetic_test/check_broadcast.sh @ 994

Last change on this file since 994 was 994, checked in by cfuguet, 9 years ago

reconf: modify the broadcast routing function to support holes in the
mesh.

  • Add a test platform in dspin_router directory that validates the introduced modifications.
  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#!/usr/bin/env sh
2# @author       Cesar Armando Fuguet Tortolero
3# @date         24 May, 2015
4# @brief        This script validates that a broadcast transaction reaches once
5#                       and only once every non-faulty router in the platform.
6file=$1
7awk '
8BEGIN {
9        sent=0
10        last=0
11        failure=0
12}
13#   Parse coordinates of routers
14#   /DSPIN_GENERATOR/ {
15#       regex="\\[[0-9]+\\]\\[";
16#       if (match($2,regex)) {
17#               x=substr($2,RSTART+1,RLENGTH-3);
18#       }
19#       regex="\\]\\[[0-9]+\\]";
20#       if (match($2,regex)) {
21#               y=substr($2,RSTART+2,RLENGTH-3);
22#       }
23#   }
24
25#   Parse the number of sent broadcast packets
26/broadcast sent packets += +/ {
27        if ($6 != 0) {
28                sent=$6;
29        }
30}
31#   Parse the number of received broadcast packets
32/broadcast received packets +=/ {
33        if ($6 == 0) {
34                zero++;
35        }
36        else {
37                # store the number of received packets of a router that actually
38                # received packets.
39                if (last == 0) {
40                        last=$6
41                }
42                # test if the error is too important. The error is defined as
43                # difference between the number of packets received by different
44                # routers.
45                error=last - $6
46                if ((error > 20) || (error < -20)) {
47                        failure=1
48                        exit;
49                }
50        }
51}
52
53#   Validate the file
54END {
55        # an error was too important
56        if (failure == 1) {
57                exit 1
58        }
59
60        # it should be only two routers that do not receive the broadcast:
61        # the source and the faulty router.
62        if (zero != 2) {
63                exit 1;
64        }
65
66        # test if the error is too important
67        error=last - sent
68        if ((error > 20) || (error < -20)) {
69                exit 1;
70        }
71
72        exit 0;
73}' $file
74if [[ $? == 1 ]]; then exit 1; fi
75
Note: See TracBrowser for help on using the repository browser.