[dpdk-stable] [PATCH v2] test: fix incorrect return types
Burakov, Anatoly
anatoly.burakov at intel.com
Tue Jul 17 14:58:03 CEST 2018
On 17-Jul-18 1:39 PM, Reshma Pattan wrote:
> UTs should return either TEST_SUCCESS or TEST_FAILED only.
> They should not return 0, -1 and any other value.
>
> Also replace one instance of setting the ret value
> from -ENOMEM to TEST_FAILED, in order to return
> correct value to autotest.
>
> Fixes: 9c9befea4f ("test: add flow classify unit tests")
> CC: jasvinder.singh at intel.com
> CC: bernard.iremonger at intel.com
> CC: stable at dpdk.org
>
> Signed-off-by: Reshma Pattan <reshma.pattan at intel.com>
> Reviewed-by: Anatoly Burakov <anatoly.burakov at intel.com>
> ---
> v2: update commit message
> ---
<snip>
> @@ -871,32 +871,32 @@ test_flow_classify(void)
> printf("Line %i: f_create has failed!\n", __LINE__);
> rte_flow_classifier_free(cls->cls);
> rte_free(cls);
> - return -1;
> + return TEST_FAILED;
> }
> printf("Created table_acl for for IPv4 five tuple packets\n");
>
> ret = init_mbufpool();
> if (ret) {
> printf("Line %i: init_mbufpool has failed!\n", __LINE__);
> - return -1;
> + return TEST_FAILED;
> }
>
> if (test_invalid_parameters() < 0)
> - return -1;
> + return TEST_FAILED;
> if (test_valid_parameters() < 0)
> - return -1;
> + return TEST_FAILED;
> if (test_invalid_patterns() < 0)
> - return -1;
> + return TEST_FAILED;
> if (test_invalid_actions() < 0)
> - return -1;
> + return TEST_FAILED;
> if (test_query_udp() < 0)
> - return -1;
> + return TEST_FAILED;
> if (test_query_tcp() < 0)
> - return -1;
> + return TEST_FAILED;
> if (test_query_sctp() < 0)
> - return -1;
> + return TEST_FAILED;
>
> - return 0;
> + return TEST_SUCCESS;
> }
>
> REGISTER_TEST_COMMAND(flow_classify_autotest, test_flow_classify);
>
I'm nitpicking now, but technically, we could've foregone large part of
this patch and just kept the part above. We don't actually care if
individual test functions return -1 or TEST_FAILED - we just need the
return from test app to be that :)
--
Thanks,
Anatoly
More information about the stable
mailing list