aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalakrishna Garapati <balakrishna.garapati@linaro.org>2016-10-20 09:34:33 +0200
committerBalakrishna Garapati <balakrishna.garapati@linaro.org>2016-10-20 09:34:33 +0200
commitdc15d52d1d90a2aceae45fbfe13cb6753e9ec683 (patch)
tree61f2a68f25141755fc9d5169f42e8d71c2a3c76a
parent2cb76e992cf3dc6c98af8090f973b0992ff7f456 (diff)
Revert "validation: diverse cosmetic fixes for checkpatch"
This reverts commit c79b041f389e56a2c713a507b75762e08d75e4b4. To match odp monarch_lts release Signed-off-by: Balakrishna Garapati <balakrishna.garapati@linaro.org>
-rw-r--r--test/performance/odp_crypto.c6
-rw-r--r--test/performance/odp_l2fwd.c1
-rwxr-xr-xtest/performance/odp_l2fwd_run.sh3
-rw-r--r--test/performance/odp_pktio_perf.c34
-rw-r--r--test/performance/odp_scheduling.c19
-rw-r--r--test/validation/classification/odp_classification_test_pmr.c1
-rw-r--r--test/validation/crypto/odp_crypto_test_inp.c32
-rw-r--r--test/validation/crypto/test_vectors.h2
-rw-r--r--test/validation/hash/hash.c1
-rw-r--r--test/validation/pktio/pktio.c2
-rw-r--r--test/validation/queue/queue.c7
-rw-r--r--test/validation/scheduler/scheduler.c13
-rw-r--r--test/validation/timer/timer.c75
13 files changed, 96 insertions, 100 deletions
diff --git a/test/performance/odp_crypto.c b/test/performance/odp_crypto.c
index 49a9f4b6f..b7818ea97 100644
--- a/test/performance/odp_crypto.c
+++ b/test/performance/odp_crypto.c
@@ -552,9 +552,11 @@ run_measure_one(crypto_args_t *cargs,
if (newpkt == ODP_PACKET_INVALID) {
app_err("failed to allocate buffer\n");
return -1;
+ } else {
+ void *mem = odp_packet_data(pkt);
+
+ memset(mem, 1, payload_length);
}
- mem = odp_packet_data(newpkt);
- memset(mem, 1, payload_length);
params.pkt = newpkt;
params.out_pkt = cargs->in_place ? newpkt :
ODP_PACKET_INVALID;
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index 418382dc1..f05aa309b 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -80,6 +80,7 @@ static inline int sched_mode(pktin_mode_t in_mode)
(in_mode == SCHED_ORDERED);
}
+
/** Get rid of path in filename - only for unix-type paths using '/' */
#define NO_PATH(file_name) (strrchr((file_name), '/') ? \
strrchr((file_name), '/') + 1 : (file_name))
diff --git a/test/performance/odp_l2fwd_run.sh b/test/performance/odp_l2fwd_run.sh
index 1fff087f2..fc3d05d6b 100755
--- a/test/performance/odp_l2fwd_run.sh
+++ b/test/performance/odp_l2fwd_run.sh
@@ -65,8 +65,7 @@ run_l2fwd()
#@todo: limit odp_generator to cores
#https://bugs.linaro.org/show_bug.cgi?id=1398
(odp_generator${EXEEXT} -I $IF0 \
- --srcip 192.168.0.1 --dstip 192.168.0.2 \
- -m u 2>&1 > /dev/null) \
+ --srcip 192.168.0.1 --dstip 192.168.0.2 -m u 2>&1 > /dev/null) \
2>&1 > /dev/null &
GEN_PID=$!
diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c
index f041b1325..18a1aa2a2 100644
--- a/test/performance/odp_pktio_perf.c
+++ b/test/performance/odp_pktio_perf.c
@@ -255,6 +255,7 @@ static int pktio_pkt_has_magic(odp_packet_t pkt)
return 0;
}
+
/*
* Allocate packets for transmission.
*/
@@ -374,8 +375,8 @@ static int run_thread_tx(void *arg)
cur_time = odp_time_local();
}
- VPRINT(" %02d: TxPkts %-8" PRIu64 " EnqFail %-6" PRIu64
- " AllocFail %-6" PRIu64 " Idle %" PRIu64 "ms\n",
+ VPRINT(" %02d: TxPkts %-8"PRIu64" EnqFail %-6"PRIu64
+ " AllocFail %-6"PRIu64" Idle %"PRIu64"ms\n",
thr_id, stats->s.tx_cnt,
stats->s.enq_failures, stats->s.alloc_failures,
odp_time_to_ns(stats->s.idle_ticks) /
@@ -416,7 +417,6 @@ static int run_thread_rx(void *arg)
test_globals_t *globals;
int thr_id, batch_len;
odp_queue_t queue = ODP_QUEUE_INVALID;
- odp_packet_t pkt;
thread_args_t *targs = arg;
@@ -445,7 +445,7 @@ static int run_thread_rx(void *arg)
for (i = 0; i < n_ev; ++i) {
if (odp_event_type(ev[i]) == ODP_EVENT_PACKET) {
- pkt = odp_packet_from_event(ev[i]);
+ odp_packet_t pkt = odp_packet_from_event(ev[i]);
if (pktio_pkt_has_magic(pkt))
stats->s.rx_cnt++;
else
@@ -498,16 +498,16 @@ static int process_results(uint64_t expected_tx_cnt,
attempted_pps = status->pps_curr;
- len += snprintf(&str[len], sizeof(str) - 1 - len,
- "PPS: %-8" PRIu64 " ", attempted_pps);
- len += snprintf(&str[len], sizeof(str) - 1 - len,
+ len += snprintf(&str[len], sizeof(str)-1-len,
+ "PPS: %-8"PRIu64" ", attempted_pps);
+ len += snprintf(&str[len], sizeof(str)-1-len,
"Succeeded: %-4s ", fail ? "No" : "Yes");
- len += snprintf(&str[len], sizeof(str) - 1 - len,
- "TxPkts: %-8" PRIu64 " ", tx_pkts);
- len += snprintf(&str[len], sizeof(str) - 1 - len,
- "RxPkts: %-8" PRIu64 " ", rx_pkts);
- len += snprintf(&str[len], sizeof(str) - 1 - len,
- "DropPkts: %-8" PRIu64 " ", drops);
+ len += snprintf(&str[len], sizeof(str)-1-len,
+ "TxPkts: %-8"PRIu64" ", tx_pkts);
+ len += snprintf(&str[len], sizeof(str)-1-len,
+ "RxPkts: %-8"PRIu64" ", rx_pkts);
+ len += snprintf(&str[len], sizeof(str)-1-len,
+ "DropPkts: %-8"PRIu64" ", drops);
printf("%s\n", str);
if (gbl_args->args.search == 0) {
@@ -537,7 +537,7 @@ static int process_results(uint64_t expected_tx_cnt,
unsigned pkt_len = gbl_args->args.pkt_len + PKT_HDR_LEN;
int mbps = (pkt_len * status->pps_pass * 8) / 1024 / 1024;
- printf("Maximum packet rate: %" PRIu64 " PPS (%d Mbps)\n",
+ printf("Maximum packet rate: %"PRIu64" PPS (%d Mbps)\n",
status->pps_pass, mbps);
return 0;
@@ -587,8 +587,8 @@ static int setup_txrx_masks(odp_cpumask_t *thd_mask_tx,
num_rx_workers = odp_cpumask_count(thd_mask_rx);
- odp_barrier_init(&gbl_args->rx_barrier, num_rx_workers + 1);
- odp_barrier_init(&gbl_args->tx_barrier, num_tx_workers + 1);
+ odp_barrier_init(&gbl_args->rx_barrier, num_rx_workers+1);
+ odp_barrier_init(&gbl_args->tx_barrier, num_tx_workers+1);
return 0;
}
@@ -978,7 +978,7 @@ static void parse_args(int argc, char *argv[], test_args_t *args)
{
char *token;
- args->if_str = malloc(strlen(optarg) + 1);
+ args->if_str = malloc(strlen(optarg)+1);
if (!args->if_str)
LOG_ABORT("Failed to alloc iface storage\n");
diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c
index 5a2997fd1..bd37f9bd4 100644
--- a/test/performance/odp_scheduling.c
+++ b/test/performance/odp_scheduling.c
@@ -28,12 +28,12 @@
/* GNU lib C */
#include <getopt.h>
-#define MSG_POOL_SIZE (4 * 1024 * 1024) /**< Message pool size */
+#define MSG_POOL_SIZE (4*1024*1024) /**< Message pool size */
#define MAX_ALLOCS 35 /**< Alloc burst size */
#define QUEUES_PER_PRIO 64 /**< Queue per priority */
#define NUM_PRIOS 2 /**< Number of tested priorities */
-#define QUEUE_ROUNDS (512 * 1024) /**< Queue test rounds */
-#define ALLOC_ROUNDS (1024 * 1024) /**< Alloc test rounds */
+#define QUEUE_ROUNDS (512*1024) /**< Queue test rounds */
+#define ALLOC_ROUNDS (1024*1024) /**< Alloc test rounds */
#define MULTI_BUFS_MAX 4 /**< Buffer burst size */
#define TEST_SEC 2 /**< Time test duration in sec */
#define STATS_PER_LINE 8 /**< Stats per printed line */
@@ -163,6 +163,7 @@ static int enqueue_events(int thr, int prio, int num_queues, int num_events,
return 0;
}
+
/**
* @internal Test single buffer alloc and free
*
@@ -227,7 +228,7 @@ static int test_alloc_multi(int thr, test_globals_t *globals)
}
for (; j > 0; j--)
- odp_buffer_free(temp_buf[j - 1]);
+ odp_buffer_free(temp_buf[j-1]);
}
c2 = odp_cpu_cycles();
@@ -384,6 +385,7 @@ static int test_schedule_single(const char *str, int thr,
return 0;
}
+
/**
* @internal Test scheduling of multiple queues - with odp_schedule()
*
@@ -531,6 +533,7 @@ static int test_schedule_multi(const char *str, int thr,
odp_schedule_resume();
+
c2 = odp_cpu_cycles();
cycles = odp_cpu_cycles_diff(c2, c1);
@@ -652,6 +655,7 @@ static int run_thread(void *arg ODP_UNUSED)
ODP_SCHED_PRIO_HIGHEST, globals))
return -1;
+
printf("Thread %i exits\n", thr);
fflush(NULL);
return 0;
@@ -764,6 +768,7 @@ static void parse_args(int argc, char *argv[], test_args_t *args)
}
}
+
/**
* Test main function
*/
@@ -852,7 +857,7 @@ int main(int argc, char *argv[])
odp_pool_param_init(&params);
params.buf.size = sizeof(test_message_t);
params.buf.align = 0;
- params.buf.num = MSG_POOL_SIZE / sizeof(test_message_t);
+ params.buf.num = MSG_POOL_SIZE/sizeof(test_message_t);
params.type = ODP_POOL_BUFFER;
pool = odp_pool_create("msg_pool", &params);
@@ -900,8 +905,8 @@ int main(int argc, char *argv[])
param.sched.group = ODP_SCHED_GROUP_ALL;
for (j = 0; j < QUEUES_PER_PRIO; j++) {
- name[9] = '0' + j / 10;
- name[10] = '0' + j - 10 * (j / 10);
+ name[9] = '0' + j/10;
+ name[10] = '0' + j - 10*(j/10);
queue = odp_queue_create(name, &param);
diff --git a/test/validation/classification/odp_classification_test_pmr.c b/test/validation/classification/odp_classification_test_pmr.c
index c8bbf50b5..7c7d07ea0 100644
--- a/test/validation/classification/odp_classification_test_pmr.c
+++ b/test/validation/classification/odp_classification_test_pmr.c
@@ -70,6 +70,7 @@ void configure_default_cos(odp_pktio_t pktio, odp_cos_t *cos,
*cos = default_cos;
*queue = default_queue;
*pool = default_pool;
+ return;
}
int classification_suite_pmr_term(void)
diff --git a/test/validation/crypto/odp_crypto_test_inp.c b/test/validation/crypto/odp_crypto_test_inp.c
index 4ac4a0700..0c5b1107c 100644
--- a/test/validation/crypto/odp_crypto_test_inp.c
+++ b/test/validation/crypto/odp_crypto_test_inp.c
@@ -53,10 +53,6 @@ static void alg_test(odp_crypto_op_t op,
odp_event_t event;
odp_crypto_compl_t compl_event;
odp_crypto_op_result_t result;
- odp_crypto_session_params_t ses_params;
- odp_crypto_op_params_t op_params;
- uint8_t *data_addr;
- int data_off;
rc = odp_crypto_capability(&capability);
CU_ASSERT(!rc);
@@ -104,6 +100,7 @@ static void alg_test(odp_crypto_op_t op,
CU_ASSERT(!rc);
/* Create a crypto session */
+ odp_crypto_session_params_t ses_params;
memset(&ses_params, 0, sizeof(ses_params));
ses_params.op = op;
ses_params.auth_cipher_text = false;
@@ -126,11 +123,12 @@ static void alg_test(odp_crypto_op_t op,
odp_packet_t pkt = odp_packet_alloc(suite_context.pool,
plaintext_len + digest_len);
CU_ASSERT(pkt != ODP_PACKET_INVALID);
- data_addr = odp_packet_data(pkt);
+ uint8_t *data_addr = odp_packet_data(pkt);
memcpy(data_addr, plaintext, plaintext_len);
- data_off = 0;
+ int data_off = 0;
/* Prepare input/output params */
+ odp_crypto_op_params_t op_params;
memset(&op_params, 0, sizeof(op_params));
op_params.session = session;
op_params.pkt = pkt;
@@ -201,10 +199,10 @@ void crypto_test_enc_alg_3des_cbc(void)
odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
auth_key = { .data = NULL, .length = 0 };
odp_crypto_iv_t iv;
- unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) /
+ unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length)/
sizeof(tdes_cbc_reference_length[0]));
- unsigned int i;
+ unsigned int i;
for (i = 0; i < test_vec_num; i++) {
cipher_key.data = tdes_cbc_reference_key[i];
cipher_key.length = sizeof(tdes_cbc_reference_key[i]);
@@ -234,10 +232,10 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
auth_key = { .data = NULL, .length = 0 };
odp_crypto_iv_t iv = { .data = NULL, .length = TDES_CBC_IV_LEN };
- unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) /
+ unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length)/
sizeof(tdes_cbc_reference_length[0]));
- unsigned int i;
+ unsigned int i;
for (i = 0; i < test_vec_num; i++) {
cipher_key.data = tdes_cbc_reference_key[i];
cipher_key.length = sizeof(tdes_cbc_reference_key[i]);
@@ -257,6 +255,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
}
}
+
/* This test verifies the correctness of decode (ciphertext -> plaintext)
* operation for 3DES_CBC algorithm. IV for the operation is the session IV
* In addition the test verifies if the implementation can use the
@@ -267,10 +266,10 @@ void crypto_test_dec_alg_3des_cbc(void)
odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
auth_key = { .data = NULL, .length = 0 };
odp_crypto_iv_t iv = { .data = NULL, .length = 0 };
- unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) /
+ unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length)/
sizeof(tdes_cbc_reference_length[0]));
- unsigned int i;
+ unsigned int i;
for (i = 0; i < test_vec_num; i++) {
cipher_key.data = tdes_cbc_reference_key[i];
cipher_key.length = sizeof(tdes_cbc_reference_key[i]);
@@ -302,10 +301,10 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
auth_key = { .data = NULL, .length = 0 };
odp_crypto_iv_t iv = { .data = NULL, .length = TDES_CBC_IV_LEN };
- unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length) /
+ unsigned int test_vec_num = (sizeof(tdes_cbc_reference_length)/
sizeof(tdes_cbc_reference_length[0]));
- unsigned int i;
+ unsigned int i;
for (i = 0; i < test_vec_num; i++) {
cipher_key.data = tdes_cbc_reference_key[i];
cipher_key.length = sizeof(tdes_cbc_reference_key[i]);
@@ -608,6 +607,7 @@ void crypto_test_dec_alg_aes128_cbc_ovr_iv(void)
}
}
+
/* This test verifies the correctness of HMAC_MD5 digest operation.
* The output check length is truncated to 12 bytes (96 bits) as
* returned by the crypto operation API call.
@@ -621,10 +621,10 @@ void crypto_test_alg_hmac_md5(void)
auth_key = { .data = NULL, .length = 0 };
odp_crypto_iv_t iv = { .data = NULL, .length = 0 };
- unsigned int test_vec_num = (sizeof(hmac_md5_reference_length) /
+ unsigned int test_vec_num = (sizeof(hmac_md5_reference_length)/
sizeof(hmac_md5_reference_length[0]));
- unsigned int i;
+ unsigned int i;
for (i = 0; i < test_vec_num; i++) {
auth_key.data = hmac_md5_reference_key[i];
auth_key.length = sizeof(hmac_md5_reference_key[i]);
diff --git a/test/validation/crypto/test_vectors.h b/test/validation/crypto/test_vectors.h
index da4610f33..1b760a24e 100644
--- a/test/validation/crypto/test_vectors.h
+++ b/test/validation/crypto/test_vectors.h
@@ -266,7 +266,7 @@ aes128_gcm_reference_ciphertext[][AES128_GCM_MAX_DATA_LEN] = {
static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] = {
{ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b },
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b } ,
/* "Jefe" */
{ 0x4a, 0x65, 0x66, 0x65 },
diff --git a/test/validation/hash/hash.c b/test/validation/hash/hash.c
index b353fcecd..feaa6aee4 100644
--- a/test/validation/hash/hash.c
+++ b/test/validation/hash/hash.c
@@ -51,4 +51,5 @@ int hash_main(int argc, char *argv[])
ret = odp_cunit_run();
return ret;
+
}
diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c
index a6a18c352..d53a4190e 100644
--- a/test/validation/pktio/pktio.c
+++ b/test/validation/pktio/pktio.c
@@ -1547,6 +1547,7 @@ void pktio_test_start_stop(void)
/* Test Rx on a stopped interface. Only works if there are 2 */
if (num_ifaces > 1) {
+
alloc = create_packets(tx_pkt, pkt_seq, 1000, pktio[0],
pktio[1]);
@@ -1590,6 +1591,7 @@ void pktio_test_start_stop(void)
}
}
+
if (num_ifaces > 1)
pktio_in = pktio[1];
else
diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c
index dc3a977cb..96941f403 100644
--- a/test/validation/queue/queue.c
+++ b/test/validation/queue/queue.c
@@ -148,7 +148,6 @@ void queue_test_param(void)
int nr_deq_entries = 0;
int max_iteration = CONFIG_MAX_ITERATION;
odp_queue_param_t qparams;
- odp_buffer_t enbuf;
/* Schedule type queue */
odp_queue_param_init(&qparams);
@@ -198,7 +197,7 @@ void queue_test_param(void)
}
for (i = 0; i < MAX_BUFFER_QUEUE; i++) {
- buf = odp_buffer_alloc(msg_pool);
+ odp_buffer_t buf = odp_buffer_alloc(msg_pool);
enev[i] = odp_buffer_to_event(buf);
}
@@ -224,7 +223,7 @@ void queue_test_param(void)
} while (nr_deq_entries < MAX_BUFFER_QUEUE);
for (i = 0; i < MAX_BUFFER_QUEUE; i++) {
- enbuf = odp_buffer_from_event(enev[i]);
+ odp_buffer_t enbuf = odp_buffer_from_event(enev[i]);
CU_ASSERT(enev[i] == deev[i]);
odp_buffer_free(enbuf);
}
@@ -284,7 +283,7 @@ void queue_test_info(void)
CU_ASSERT(info.param.sched.group == odp_queue_sched_group(q_order));
ret = odp_queue_lock_count(q_order);
CU_ASSERT(ret >= 0);
- lock_count = (unsigned)ret;
+ lock_count = (unsigned) ret;
CU_ASSERT(info.param.sched.lock_count == lock_count);
CU_ASSERT(odp_queue_destroy(q_plain) == 0);
diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c
index 919cfb6ce..316370d4f 100644
--- a/test/validation/scheduler/scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -676,9 +676,6 @@ static int schedule_common_(void *arg)
odp_pool_t pool;
int locked;
int num;
- odp_event_t ev;
- odp_buffer_t buf, buf_cpy;
- odp_queue_t from;
globals = args->globals;
sync = args->sync;
@@ -690,7 +687,9 @@ static int schedule_common_(void *arg)
odp_barrier_wait(&globals->barrier);
while (1) {
- from = ODP_QUEUE_INVALID;
+ odp_event_t ev;
+ odp_buffer_t buf, buf_cpy;
+ odp_queue_t from = ODP_QUEUE_INVALID;
num = 0;
odp_ticketlock_lock(&globals->lock);
@@ -903,8 +902,6 @@ static void fill_queues(thread_args_t *args)
test_globals_t *globals;
char name[32];
int ret;
- odp_buffer_t buf;
- odp_event_t ev;
globals = args->globals;
sync = args->sync;
@@ -940,6 +937,8 @@ static void fill_queues(thread_args_t *args)
CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);
for (k = 0; k < args->num_bufs; k++) {
+ odp_buffer_t buf;
+ odp_event_t ev;
buf = odp_buffer_alloc(pool);
CU_ASSERT_FATAL(buf != ODP_BUFFER_INVALID);
ev = odp_buffer_to_event(buf);
@@ -1333,7 +1332,6 @@ static int create_queues(void)
odp_buffer_t queue_ctx_buf;
queue_context *qctx, *pqctx;
uint32_t ndx;
- odp_queue_param_t p;
if (odp_queue_capability(&capa) < 0) {
printf("Queue capability query failed\n");
@@ -1361,6 +1359,7 @@ static int create_queues(void)
}
for (i = 0; i < prios; i++) {
+ odp_queue_param_t p;
odp_queue_param_init(&p);
p.type = ODP_QUEUE_TYPE_SCHED;
p.sched.prio = i;
diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c
index 0007639cc..33eb47896 100644
--- a/test/validation/timer/timer.c
+++ b/test/validation/timer/timer.c
@@ -251,8 +251,7 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick)
CU_FAIL("Wrong status (stale) for fresh timeout");
/* Fresh timeout => local timer must have matching tick */
if (ttp && ttp->tick != tick) {
- LOG_DBG("Wrong tick: expected %" PRIu64
- " actual %" PRIu64 "\n",
+ LOG_DBG("Wrong tick: expected %" PRIu64 " actual %" PRIu64 "\n",
ttp->tick, tick);
CU_FAIL("odp_timeout_tick() wrong tick");
}
@@ -260,8 +259,7 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick)
if (tick > odp_timer_current_tick(tp))
CU_FAIL("Timeout delivered early");
if (tick < prev_tick) {
- LOG_DBG("Too late tick: %" PRIu64
- " prev_tick %" PRIu64"\n",
+ LOG_DBG("Too late tick: %" PRIu64 " prev_tick %" PRIu64"\n",
tick, prev_tick);
/* We don't report late timeouts using CU_FAIL */
odp_atomic_inc_u32(&ndelivtoolate);
@@ -283,26 +281,12 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
uint32_t i, allocated;
unsigned seed = thr;
int rc;
- odp_queue_t queue;
- struct test_timer *tt;
- uint32_t nset;
- uint64_t tck;
- uint32_t nrcv;
- uint32_t nreset;
- uint32_t ncancel;
- uint32_t ntoolate;
- uint32_t ms;
- uint64_t prev_tick;
- odp_event_t ev;
- struct timespec ts;
- uint32_t nstale;
- odp_timer_set_t timer_rc;
- queue = odp_queue_create("timer_queue", NULL);
+ odp_queue_t queue = odp_queue_create("timer_queue", NULL);
if (queue == ODP_QUEUE_INVALID)
CU_FAIL_FATAL("Queue create failed");
- tt = malloc(sizeof(struct test_timer) * NTIMERS);
+ struct test_timer *tt = malloc(sizeof(struct test_timer) * NTIMERS);
if (!tt)
CU_FAIL_FATAL("malloc failed");
@@ -332,13 +316,15 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
odp_barrier_wait(&test_barrier);
/* Initial set all timers with a random expiration time */
- nset = 0;
+ uint32_t nset = 0;
for (i = 0; i < allocated; i++) {
- tck = odp_timer_current_tick(tp) + 1 +
- odp_timer_ns_to_tick(tp, (rand_r(&seed) % RANGE_MS)
- * 1000000ULL);
- timer_rc = odp_timer_set_abs(tt[i].tim, tck, &tt[i].ev);
- if (timer_rc != ODP_TIMER_SUCCESS) {
+ uint64_t tck = odp_timer_current_tick(tp) + 1 +
+ odp_timer_ns_to_tick(tp,
+ (rand_r(&seed) % RANGE_MS)
+ * 1000000ULL);
+ odp_timer_set_t rc;
+ rc = odp_timer_set_abs(tt[i].tim, tck, &tt[i].ev);
+ if (rc != ODP_TIMER_SUCCESS) {
CU_FAIL("Failed to set timer");
} else {
tt[i].tick = tck;
@@ -347,13 +333,15 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
}
/* Step through wall time, 1ms at a time and check for expired timers */
- nrcv = 0;
- nreset = 0;
- ncancel = 0;
- ntoolate = 0;
- prev_tick = odp_timer_current_tick(tp);
+ uint32_t nrcv = 0;
+ uint32_t nreset = 0;
+ uint32_t ncancel = 0;
+ uint32_t ntoolate = 0;
+ uint32_t ms;
+ uint64_t prev_tick = odp_timer_current_tick(tp);
for (ms = 0; ms < 7 * RANGE_MS / 10 && allocated > 0; ms++) {
+ odp_event_t ev;
while ((ev = odp_queue_deq(queue)) != ODP_EVENT_INVALID) {
/* Subtract one from prev_tick to allow for timeouts
* to be delivered a tick late */
@@ -400,6 +388,7 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
tt[i].tick = cur_tick + tck;
}
}
+ struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 1000000; /* 1ms */
if (nanosleep(&ts, NULL) < 0)
@@ -407,7 +396,7 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
}
/* Cancel and free all timers */
- nstale = 0;
+ uint32_t nstale = 0;
for (i = 0; i < allocated; i++) {
(void)odp_timer_cancel(tt[i].tim, &tt[i].ev);
tt[i].tick = TICK_INVALID;
@@ -423,22 +412,22 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
LOG_DBG("Thread %u: %" PRIu32 " timers reset/cancelled too late\n",
thr, ntoolate);
LOG_DBG("Thread %u: %" PRIu32 " timeouts received\n", thr, nrcv);
- LOG_DBG("Thread %u: %" PRIu32
- " stale timeout(s) after odp_timer_free()\n",
+ LOG_DBG("Thread %u: %" PRIu32 " stale timeout(s) after odp_timer_free()\n",
thr, nstale);
/* Delay some more to ensure timeouts for expired timers can be
* received. Can not use busy loop here to make background timer
* thread finish their work. */
+ struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = (3 * RANGE_MS / 10 + 50) * ODP_TIME_MSEC_IN_NS;
if (nanosleep(&ts, NULL) < 0)
CU_FAIL_FATAL("nanosleep failed");
while (nstale != 0) {
- ev = odp_queue_deq(queue);
+ odp_event_t ev = odp_queue_deq(queue);
if (ev != ODP_EVENT_INVALID) {
- handle_tmo(ev, true, 0/*Don't care for stale tmo's*/);
+ handle_tmo(ev, true, 0/*Dont' care for stale tmo's*/);
nstale--;
} else {
CU_FAIL("Failed to receive stale timeout");
@@ -452,7 +441,7 @@ static int worker_entrypoint(void *arg TEST_UNUSED)
}
/* Check if there any more (unexpected) events */
- ev = odp_queue_deq(queue);
+ odp_event_t ev = odp_queue_deq(queue);
if (ev != ODP_EVENT_INVALID)
CU_FAIL("Unexpected event received");
@@ -475,11 +464,6 @@ void timer_test_odp_timer_all(void)
odp_pool_param_t params;
odp_timer_pool_param_t tparam;
odp_cpumask_t unused;
- odp_timer_pool_info_t tpinfo;
- uint64_t tick;
- uint64_t ns;
- uint64_t t2;
- pthrd_arg thrdarg;
/* Reserve at least one core for running other processes so the timer
* test hopefully can run undisturbed and thus get better timing
@@ -521,6 +505,7 @@ void timer_test_odp_timer_all(void)
/* Start all created timer pools */
odp_timer_pool_start();
+ odp_timer_pool_info_t tpinfo;
if (odp_timer_pool_info(tp, &tpinfo) != 0)
CU_FAIL("odp_timer_pool_info");
CU_ASSERT(strcmp(tpinfo.name, NAME) == 0);
@@ -534,9 +519,10 @@ void timer_test_odp_timer_all(void)
LOG_DBG("Tmo range: %u ms (%" PRIu64 " ticks)\n", RANGE_MS,
odp_timer_ns_to_tick(tp, 1000000ULL * RANGE_MS));
+ uint64_t tick;
for (tick = 0; tick < 1000000000000ULL; tick += 1000000ULL) {
- ns = odp_timer_tick_to_ns(tp, tick);
- t2 = odp_timer_ns_to_tick(tp, ns);
+ uint64_t ns = odp_timer_tick_to_ns(tp, tick);
+ uint64_t t2 = odp_timer_ns_to_tick(tp, ns);
if (tick != t2)
CU_FAIL("Invalid conversion tick->ns->tick");
}
@@ -551,6 +537,7 @@ void timer_test_odp_timer_all(void)
odp_atomic_init_u32(&timers_allocated, 0);
/* Create and start worker threads */
+ pthrd_arg thrdarg;
thrdarg.testcase = 0;
thrdarg.numthrds = num_workers;
odp_cunit_thread_create(worker_entrypoint, &thrdarg);