diff mbox

example: odp_switch add termination path

Message ID 1468939362-22943-1-git-send-email-maxim.uvarov@linaro.org
State Accepted
Commit b7d403b9f8b8f666259dccf9d994ef8a28d9facb
Headers show

Commit Message

Maxim Uvarov July 19, 2016, 2:42 p.m. UTC
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
 example/switch/odp_switch.c  | 19 +++++++++++++++++--
 example/switch/switch_run.sh | 11 +++--------
 2 files changed, 20 insertions(+), 10 deletions(-)

-- 
2.7.1.250.gff4ea60

Comments

Mike Holmes July 19, 2016, 9:17 p.m. UTC | #1
On 19 July 2016 at 10:42, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

>


Reviewed-by: Mike Holmes <mike.holmes@linaro.org>



> ---

>  example/switch/odp_switch.c  | 19 +++++++++++++++++--

>  example/switch/switch_run.sh | 11 +++--------

>  2 files changed, 20 insertions(+), 10 deletions(-)

>

> diff --git a/example/switch/odp_switch.c b/example/switch/odp_switch.c

> index c48a202..4b944fe 100644

> --- a/example/switch/odp_switch.c

> +++ b/example/switch/odp_switch.c

> @@ -376,7 +376,7 @@ static int print_speed_stats(int num_workers, stats_t

> (*thr_stats)[MAX_PKTIOS],

>

>         } while (loop_forever || (elapsed < duration));

>

> -       return rx_pkts_tot > 100 ? 0 : -1;

> +       return rx_pkts_tot >= 100 ? 0 : -1;

>  }

>

>  /**

> @@ -1033,7 +1033,22 @@ int main(int argc, char **argv)

>

>         free(gbl_args->appl.if_names);

>         free(gbl_args->appl.if_str);

> -       printf("Exit\n\n");

>

> +       if (odp_pool_destroy(gbl_args->pool)) {

> +               printf("Error: pool destroy\n");

> +               exit(EXIT_FAILURE);

> +       }

> +

> +       if (odp_term_local()) {

> +               printf("Error: term local\n");

> +               exit(EXIT_FAILURE);

> +       }

> +

> +       if (odp_term_global(instance)) {

> +               printf("Error: term global\n");

> +               exit(EXIT_FAILURE);

> +       }

> +

> +       printf("Exit: %d\n\n", ret);

>         return ret;

>  }

> diff --git a/example/switch/switch_run.sh b/example/switch/switch_run.sh

> index 3f8f9db..d9aa8bd 100755

> --- a/example/switch/switch_run.sh

> +++ b/example/switch/switch_run.sh

> @@ -19,15 +19,10 @@ do

>         RX_PORTS="${RX_PORTS},pcap:out=pcapout${i}.pcap"

>  done

>

> -./odp_switch -i pcap:in=${PCAP_IN}${RX_PORTS} &

> -

> -sleep 1

> -kill $!

> -wait $!

> +./odp_switch -i pcap:in=${PCAP_IN}${RX_PORTS} -t 1

>  STATUS=$?

> -

> -if [ "$STATUS" -ne 143 ]; then

> -  echo "Error: status was: $STATUS, expected 143"

> +if [ "$STATUS" -ne 0 ]; then

> +  echo "Error: status was: $STATUS, expected 0"

>    RETVAL=1

>  fi

>

> --

> 2.7.1.250.gff4ea60

>

>



-- 
Mike Holmes
Technical Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"
Maxim Uvarov July 20, 2016, 1:02 p.m. UTC | #2
Merged,
Maxim.

On 07/20/16 00:17, Mike Holmes wrote:
>

>

> On 19 July 2016 at 10:42, Maxim Uvarov <maxim.uvarov@linaro.org 

> <mailto:maxim.uvarov@linaro.org>> wrote:

>

>     Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org

>     <mailto:maxim.uvarov@linaro.org>>

>

>

> Reviewed-by: Mike Holmes <mike.holmes@linaro.org 

> <mailto:mike.holmes@linaro.org>>

>

>     ---

>      example/switch/odp_switch.c  | 19 +++++++++++++++++--

>      example/switch/switch_run.sh | 11 +++--------

>      2 files changed, 20 insertions(+), 10 deletions(-)

>

>     diff --git a/example/switch/odp_switch.c b/example/switch/odp_switch.c

>     index c48a202..4b944fe 100644

>     --- a/example/switch/odp_switch.c

>     +++ b/example/switch/odp_switch.c

>     @@ -376,7 +376,7 @@ static int print_speed_stats(int num_workers,

>     stats_t (*thr_stats)[MAX_PKTIOS],

>

>             } while (loop_forever || (elapsed < duration));

>

>     -       return rx_pkts_tot > 100 ? 0 : -1;

>     +       return rx_pkts_tot >= 100 ? 0 : -1;

>      }

>

>      /**

>     @@ -1033,7 +1033,22 @@ int main(int argc, char **argv)

>

>             free(gbl_args->appl.if_names);

>             free(gbl_args->appl.if_str);

>     -       printf("Exit\n\n");

>

>     +       if (odp_pool_destroy(gbl_args->pool)) {

>     +               printf("Error: pool destroy\n");

>     +               exit(EXIT_FAILURE);

>     +       }

>     +

>     +       if (odp_term_local()) {

>     +               printf("Error: term local\n");

>     +               exit(EXIT_FAILURE);

>     +       }

>     +

>     +       if (odp_term_global(instance)) {

>     +               printf("Error: term global\n");

>     +               exit(EXIT_FAILURE);

>     +       }

>     +

>     +       printf("Exit: %d\n\n", ret);

>             return ret;

>      }

>     diff --git a/example/switch/switch_run.sh

>     b/example/switch/switch_run.sh

>     index 3f8f9db..d9aa8bd 100755

>     --- a/example/switch/switch_run.sh

>     +++ b/example/switch/switch_run.sh

>     @@ -19,15 +19,10 @@ do

>             RX_PORTS="${RX_PORTS},pcap:out=pcapout${i}.pcap"

>      done

>

>     -./odp_switch -i pcap:in=${PCAP_IN}${RX_PORTS} &

>     -

>     -sleep 1

>     -kill $!

>     -wait $!

>     +./odp_switch -i pcap:in=${PCAP_IN}${RX_PORTS} -t 1

>      STATUS=$?

>     -

>     -if [ "$STATUS" -ne 143 ]; then

>     -  echo "Error: status was: $STATUS, expected 143"

>     +if [ "$STATUS" -ne 0 ]; then

>     +  echo "Error: status was: $STATUS, expected 0"

>        RETVAL=1

>      fi

>

>     --

>     2.7.1.250.gff4ea60

>

>

>

>

> -- 

> Mike Holmes

> Technical Manager - Linaro Networking Group

> Linaro.org <http://www.linaro.org/>***│ *Open source software for ARM SoCs

> "Work should be fun and collaborative, the rest follows"

>
diff mbox

Patch

diff --git a/example/switch/odp_switch.c b/example/switch/odp_switch.c
index c48a202..4b944fe 100644
--- a/example/switch/odp_switch.c
+++ b/example/switch/odp_switch.c
@@ -376,7 +376,7 @@  static int print_speed_stats(int num_workers, stats_t (*thr_stats)[MAX_PKTIOS],
 
 	} while (loop_forever || (elapsed < duration));
 
-	return rx_pkts_tot > 100 ? 0 : -1;
+	return rx_pkts_tot >= 100 ? 0 : -1;
 }
 
 /**
@@ -1033,7 +1033,22 @@  int main(int argc, char **argv)
 
 	free(gbl_args->appl.if_names);
 	free(gbl_args->appl.if_str);
-	printf("Exit\n\n");
 
+	if (odp_pool_destroy(gbl_args->pool)) {
+		printf("Error: pool destroy\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if (odp_term_local()) {
+		printf("Error: term local\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if (odp_term_global(instance)) {
+		printf("Error: term global\n");
+		exit(EXIT_FAILURE);
+	}
+
+	printf("Exit: %d\n\n", ret);
 	return ret;
 }
diff --git a/example/switch/switch_run.sh b/example/switch/switch_run.sh
index 3f8f9db..d9aa8bd 100755
--- a/example/switch/switch_run.sh
+++ b/example/switch/switch_run.sh
@@ -19,15 +19,10 @@  do
 	RX_PORTS="${RX_PORTS},pcap:out=pcapout${i}.pcap"
 done
 
-./odp_switch -i pcap:in=${PCAP_IN}${RX_PORTS} &
-
-sleep 1
-kill $!
-wait $!
+./odp_switch -i pcap:in=${PCAP_IN}${RX_PORTS} -t 1
 STATUS=$?
-
-if [ "$STATUS" -ne 143 ]; then
-  echo "Error: status was: $STATUS, expected 143"
+if [ "$STATUS" -ne 0 ]; then
+  echo "Error: status was: $STATUS, expected 0"
   RETVAL=1
 fi