From 61b14b226f28b752f06b54cecccc651e1a5612ed Mon Sep 17 00:00:00 2001 From: Petlozu Pravareshwar Date: Tue, 21 Jan 2020 05:10:02 -0800 Subject: [PATCH] gpu: nvgpu: Update unit test for posix queue unit Update unit test for posix queue unit to cover a missing branch. Also add posix queue SWUTS file path in "SWUTS.sources". Jira NVGPU-4478 Change-Id: Ib32969bc358d76686a03708f120da7da113c9533 Signed-off-by: Petlozu Pravareshwar Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2282988 Tested-by: mobile promotions Reviewed-by: mobile promotions --- userspace/SWUTS.sources | 1 + userspace/units/posix/queue/posix-queue.c | 18 ++++++++++++++---- userspace/units/posix/queue/posix-queue.h | 16 +++++++++------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/userspace/SWUTS.sources b/userspace/SWUTS.sources index c7455a5e1..dbc36f769 100644 --- a/userspace/SWUTS.sources +++ b/userspace/SWUTS.sources @@ -82,6 +82,7 @@ INPUT += ../../../userspace/units/sync/nvgpu-sync.h INPUT += ../../../userspace/units/posix/bitops/posix-bitops.h INPUT += ../../../userspace/units/posix/bug/posix-bug.h INPUT += ../../../userspace/units/posix/cond/posix-cond.h +INPUT += ../../../userspace/units/posix/queue/posix-queue.h INPUT += ../../../userspace/units/posix/fault-injection/posix-fault-injection.h INPUT += ../../../userspace/units/posix/fault-injection/posix-fault-injection-kmem.h INPUT += ../../../userspace/units/posix/fault-injection/posix-fault-injection-dma-alloc.h diff --git a/userspace/units/posix/queue/posix-queue.c b/userspace/units/posix/queue/posix-queue.c index d96d96822..effcdccfa 100644 --- a/userspace/units/posix/queue/posix-queue.c +++ b/userspace/units/posix/queue/posix-queue.c @@ -141,7 +141,7 @@ int test_nvgpu_queue_in(struct unit_module *m, struct gk20a *g, void *args) } /* - * Reset "in" and "out" indexes and enueue message of length BUF_LEN + * Reset "in" and "out" indexes and enqueue message of length BUF_LEN * with the lock. */ q.in = 0; @@ -153,7 +153,7 @@ int test_nvgpu_queue_in(struct unit_module *m, struct gk20a *g, void *args) goto fail; } - /* Enueue message of length BUF_LEN again and expect memory full */ + /* Enqueue message of length BUF_LEN again and expect memory full */ ret = nvgpu_queue_in_locked(&q, buf, BUF_LEN, &lock); if (ret != -ENOMEM) { err = UNIT_FAIL; @@ -161,6 +161,16 @@ int test_nvgpu_queue_in(struct unit_module *m, struct gk20a *g, void *args) goto fail; } + /* Enqueue message of length BUF_LEN again (without lock) and expect + * memory full. + */ + ret = nvgpu_queue_in(&q, buf, BUF_LEN); + if (ret != -ENOMEM) { + err = UNIT_FAIL; + unit_err(m, "%d. queue_in failed err=%d\n", __LINE__, ret); + goto fail; + } + fail: if (q.data != NULL) free(q.data); @@ -203,7 +213,7 @@ int test_nvgpu_queue_out(struct unit_module *m, struct gk20a *g, void *args) } /* - * Advance "in" index by "BUF_LEN" and deueue message of length BUF_LEN. + * Advance "in" index by "BUF_LEN" and dequeue message of length BUF_LEN */ q.in = BUF_LEN; q.out = 0; @@ -215,7 +225,7 @@ int test_nvgpu_queue_out(struct unit_module *m, struct gk20a *g, void *args) } /* - * Advance "in" index by "BUF_LEN" and deueue message of length BUF_LEN + * Advance "in" index by "BUF_LEN" and dequeue message of length BUF_LEN * with the lock. */ q.in = BUF_LEN; diff --git a/userspace/units/posix/queue/posix-queue.h b/userspace/units/posix/queue/posix-queue.h index 0f70bc7c7..6c0d7de96 100644 --- a/userspace/units/posix/queue/posix-queue.h +++ b/userspace/units/posix/queue/posix-queue.h @@ -34,7 +34,7 @@ * Test specification for: test_nvgpu_queue_alloc_and_free * * Description: Functionalities of posix queue such as allocating and freeing - * of the message queue are are tested. + * of the message queue are tested. * * Test Type: Feature, Error guessing, Boundary values * @@ -93,11 +93,13 @@ int test_nvgpu_queue_alloc_and_free(struct unit_module *m, struct gk20a *g, * - Update "in" and "out" indexes and enqueue message of length BUF_LEN such * that we wrap around the Queue while enqueuing the message using * nvgpu_queue_in() API. Check that the API returns "BUF_LEN". - * - Reset "in" and "out" indexes and enueue message of length "BUF_LEN" with + * - Reset "in" and "out" indexes and enqueue message of length "BUF_LEN" with * the lock using nvgpu_queue_in_locked() API. Check that the API returns * "BUF_LEN". - * - Enueue message of length "BUF_LEN" again using nvgpu_queue_in_locked() API. - * Check that the API returns error "-ENOMEM". + * - Enqueue message of length "BUF_LEN" again using nvgpu_queue_in_locked() + * API. Check that the API returns error "-ENOMEM". + * - Enqueue message of length "BUF_LEN" again using nvgpu_queue_in() API. Check + * that the API returns error "-ENOMEM". * - Uninitialize the allocated resources. * * Output: Returns PASS if the steps above were executed successfully. FAIL @@ -109,7 +111,7 @@ int test_nvgpu_queue_in(struct unit_module *m, struct gk20a *g, void *args); * Test specification for: test_nvgpu_queue_out * * Description: Functionalities of posix queue such as allocating queue and - * dequeueing messages from the queue are tested. + * dequeuing messages from the queue are tested. * * Test Type: Feature, Error guessing, Boundary values * @@ -127,9 +129,9 @@ int test_nvgpu_queue_in(struct unit_module *m, struct gk20a *g, void *args); * - Dequeue message of length "BUF_LEN" from the empty queue calling * nvgpu_queue_out_locked() API and check that the API returns "-ENOMEM" * error. - * - Advance "in" index by "BUF_LEN" and deueue message of length BUF_LEN by + * - Advance "in" index by "BUF_LEN" and dequeue message of length BUF_LEN by * calling nvgpu_queue_out() API and check that the API returns "BUF_LEN". - * - Advance "in" index by "BUF_LEN" and deueue message of length BUF_LEN by + * - Advance "in" index by "BUF_LEN" and dequeue message of length BUF_LEN by * calling nvgpu_queue_out_locked() API and check that the API returns * "BUF_LEN". * - Update "in" and "out" indexes and dequeue message of length BUF_LEN such