Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1341494lqp; Mon, 15 Apr 2024 03:43:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqH8npYEuQX+4+jMcVB6wAgdL2FhioWqGQhoS7yjh2G2Zt7Dzzg5ycxtCUaZh+XYzlNDoK6EZTkWhabQu5luEpMbmUSO/xqFziAGbxug== X-Google-Smtp-Source: AGHT+IHW4sWj/deWRGFp6RsrPbXaKpeN8kqxHBF/toOfGDVeqRbMWyeNv9TdFHf0pQUC4hJy6U0u X-Received: by 2002:a05:6a20:6a0d:b0:1a7:514a:81f2 with SMTP id p13-20020a056a206a0d00b001a7514a81f2mr14181152pzk.25.1713177806009; Mon, 15 Apr 2024 03:43:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713177805; cv=pass; d=google.com; s=arc-20160816; b=bPM11A/5kUWWbeQgQWV/RvxIt5tBrZIVeRXqH92DyXeLG3uO5sTSlcP6N0mmTg5z9/ 4rXQggOYhhgZxglsQSWdQpcvNFxOBUS+m7nzFWnCmkI0Et6d/6/qaIE8vLj7XgTtxbrh DXaxPhbCZKE3MCfLOBY6MYftydFf5AxqySL6B2cqGKUVmVFP7MJBnOdL2c6sO+6SDrIq NYJiqZDZj70ABmDrcF74L0H3T3APYSChPQJ65aI8A8iHTFWSWrAhVscptIcv/9ikgh31 VofcRHuKPpFhPUyW60mv5vPJCS1TrpIDLcP7OSnWEKFd12BvVFiMlC/Wg+3SPGC98NlJ SH0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=YhndftR6DNyRt0cz/Q4vt9Y/NE2TVtIDHmqYihO7DC4=; fh=xwHMhG1LOSBxzw0bPlV6CHSUfvhRrhI9RgH7m5Zh7Ws=; b=Z4QDr3PiY+G0tC57b9AZBPMWDjZLEf8iHHkLCCuBNk+RPNFuajbCZ+C8QE5cq6ml3U nUKJ4twwyvLIKx8blmJC91ZDSWQ4/iNJIbc7EjAzOJfgMaBqLWnqU3tlo9mWhDePY4xm UDiLzx7MT8j6AnpXPbpIhJGmjQrDySdD60yZKcDgbhKcnNi7/rW0pKfuPNQEaE2t7yOA KFJrvXudRoULmo6OvczKO5oLO0ORsxS6o7WTuEKlQ8QL2YY13peQbP11p//ObEP2Zr6Q zZKeisVpYXXdfYdgVnH1UiCwuUFfZN5exBpDBwQgqdicjg6IGKHWcBnqv5AzyGYGJJX7 YcvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=cqy6cnAQ; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-144925-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144925-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i12-20020a17090a718c00b002a214986325si7841673pjk.12.2024.04.15.03.43.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 03:43:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144925-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=cqy6cnAQ; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-144925-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144925-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CDE86284E63 for ; Mon, 15 Apr 2024 10:42:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E92E95D744; Mon, 15 Apr 2024 10:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="cqy6cnAQ" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 968F95CDD9; Mon, 15 Apr 2024 10:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713177745; cv=none; b=cBUGuqFp1b6tYyui+ExTrPqZzvPI2xkMF4F2CAolssKP0Cxd6n3ojmyc3ZQwrtCxqh3K2Cdk6ks+C9zcFrQ+4YAzuNtrIvuBTkZx9I4joaq1lzaSAQvl1/TCwyFKL0b0se8QD9GNh+6ovmGrF9i9Ty5wCJIY7Ih1Y9AY8TuZ91Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713177745; c=relaxed/simple; bh=56BtiIzmeYtQZJ4lAPXABBJZc3E68O0+qIolSez9oYY=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=QN1wboHiv+YePG5lp9l2iJF5Kru/q5VovNmRmK4lOPnZAtqsKkwmQWD+yrUvQHeMmMKPNYtO7E2ClAh/L7kb4IE9zeVBwxqcjgvCCn9Gl8jp0FOqNrGqb1E4i2iE6J5nNdDXXOv210cgNcDIR7RFwN7EpxlAffIa14DxxI4rVHI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=cqy6cnAQ; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713177742; bh=56BtiIzmeYtQZJ4lAPXABBJZc3E68O0+qIolSez9oYY=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=cqy6cnAQkILvH91AueQ4W0q+8myLCWFKt0yyzreJSHBJ8psonZI4ShVAZOHxY+4i3 D+NxNt262KQ1UXG67VSTPZNyWd1N7p8r5zZa/+gy5ayKx/63eLG6wB7nt/QF8z+mhL Kc3iAD8QI+FlLiihlS1FXYzHDyqC0eLNNjGy+Q7iDZye+SgjDB4DJ7xbjx4K8F5nTt 2Sw9IxtNv/Kk+e1RAi8mAWehMEfsE0/pr9/Kw4z+ELpjtuGgE46tVwCH3vFCh1ghFc 17gj/qbGPujf4RriMYVfo89IbAucIP70L69ZLDLzu3vXZRmUsaTSnujIIh2RI3lxau OZ55gknXzaIvg== Received: from [100.113.15.66] (ec2-34-240-57-77.eu-west-1.compute.amazonaws.com [34.240.57.77]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 924C93782039; Mon, 15 Apr 2024 10:42:20 +0000 (UTC) Message-ID: Date: Mon, 15 Apr 2024 15:42:54 +0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , kernel@collabora.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6] selftests/dmabuf-heap: conform test to TAP format output To: Shuah Khan , "T.J. Mercier" References: <20240327115353.3634735-1-usama.anjum@collabora.com> <84cd09fe-0d80-4e30-a8ab-3da7a1d43089@collabora.com> <18270cdc-e749-4982-8ae3-879133fcee8d@collabora.com> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: <18270cdc-e749-4982-8ae3-879133fcee8d@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit I may d missed the acceptance email. The patch is already in the next. On 4/14/24 6:22 PM, Muhammad Usama Anjum wrote: > Kind reminder > > On 4/4/24 4:49 PM, Muhammad Usama Anjum wrote: >> Soft reminder >> >> On 3/27/24 4:53 PM, Muhammad Usama Anjum wrote: >>> Conform the layout, informational and status messages to TAP. No >>> functional change is intended other than the layout of output messages. >>> Improve the TAP messages as well. >>> >>> Reviewed-by: T.J. Mercier >>> Signed-off-by: Muhammad Usama Anjum >>> --- >>> Changes since v5: >>> - Make the TAP messages more by adding more informat >>> >>> Changes since v4: >>> - close fds correctly with code changes added in v3 >>> >>> Chanages since v3: >>> - abort test-case instead of exiting if heap/mem allocation fails >>> - Correct test_alloc_zeroed() test case in case of failure >>> >>> Changes since v2: >>> - Minor improvements in test_alloc_zeroed() results >>> >>> Changes since v1: >>> - Update some more error handling code >>> --- >>> .../selftests/dmabuf-heaps/dmabuf-heap.c | 247 +++++++----------- >>> 1 file changed, 101 insertions(+), 146 deletions(-) >>> >>> diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c >>> index 890a8236a8ba7..5f541522364fb 100644 >>> --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c >>> +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c >>> @@ -15,6 +15,7 @@ >>> #include >>> #include >>> #include >>> +#include "../kselftest.h" >>> >>> #define DEVPATH "/dev/dma_heap" >>> >>> @@ -90,14 +91,13 @@ static int dmabuf_heap_open(char *name) >>> char buf[256]; >>> >>> ret = snprintf(buf, 256, "%s/%s", DEVPATH, name); >>> - if (ret < 0) { >>> - printf("snprintf failed!\n"); >>> - return ret; >>> - } >>> + if (ret < 0) >>> + ksft_exit_fail_msg("snprintf failed! %d\n", ret); >>> >>> fd = open(buf, O_RDWR); >>> if (fd < 0) >>> - printf("open %s failed!\n", buf); >>> + ksft_exit_fail_msg("open %s failed: %s\n", buf, strerror(errno)); >>> + >>> return fd; >>> } >>> >>> @@ -140,7 +140,7 @@ static int dmabuf_sync(int fd, int start_stop) >>> >>> #define ONE_MEG (1024 * 1024) >>> >>> -static int test_alloc_and_import(char *heap_name) >>> +static void test_alloc_and_import(char *heap_name) >>> { >>> int heap_fd = -1, dmabuf_fd = -1, importer_fd = -1; >>> uint32_t handle = 0; >>> @@ -148,27 +148,19 @@ static int test_alloc_and_import(char *heap_name) >>> int ret; >>> >>> heap_fd = dmabuf_heap_open(heap_name); >>> - if (heap_fd < 0) >>> - return -1; >>> >>> - printf(" Testing allocation and importing: "); >>> + ksft_print_msg("Testing allocation and importing:\n"); >>> ret = dmabuf_heap_alloc(heap_fd, ONE_MEG, 0, &dmabuf_fd); >>> if (ret) { >>> - printf("FAIL (Allocation Failed!)\n"); >>> - ret = -1; >>> - goto out; >>> + ksft_test_result_fail("FAIL (Allocation Failed!) %d\n", ret); >>> + return; >>> } >>> + >>> /* mmap and write a simple pattern */ >>> - p = mmap(NULL, >>> - ONE_MEG, >>> - PROT_READ | PROT_WRITE, >>> - MAP_SHARED, >>> - dmabuf_fd, >>> - 0); >>> + p = mmap(NULL, ONE_MEG, PROT_READ | PROT_WRITE, MAP_SHARED, dmabuf_fd, 0); >>> if (p == MAP_FAILED) { >>> - printf("FAIL (mmap() failed)\n"); >>> - ret = -1; >>> - goto out; >>> + ksft_test_result_fail("FAIL (mmap() failed): %s\n", strerror(errno)); >>> + goto close_and_return; >>> } >>> >>> dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START); >>> @@ -178,71 +170,64 @@ static int test_alloc_and_import(char *heap_name) >>> >>> importer_fd = open_vgem(); >>> if (importer_fd < 0) { >>> - ret = importer_fd; >>> - printf("(Could not open vgem - skipping): "); >>> + ksft_test_result_skip("Could not open vgem %d\n", importer_fd); >>> } else { >>> ret = import_vgem_fd(importer_fd, dmabuf_fd, &handle); >>> - if (ret < 0) { >>> - printf("FAIL (Failed to import buffer)\n"); >>> - goto out; >>> - } >>> + ksft_test_result(ret >= 0, "Import buffer %d\n", ret); >>> } >>> >>> ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START); >>> if (ret < 0) { >>> - printf("FAIL (DMA_BUF_SYNC_START failed!)\n"); >>> + ksft_print_msg("FAIL (DMA_BUF_SYNC_START failed!) %d\n", ret); >>> goto out; >>> } >>> >>> memset(p, 0xff, ONE_MEG); >>> ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_END); >>> if (ret < 0) { >>> - printf("FAIL (DMA_BUF_SYNC_END failed!)\n"); >>> + ksft_print_msg("FAIL (DMA_BUF_SYNC_END failed!) %d\n", ret); >>> goto out; >>> } >>> >>> close_handle(importer_fd, handle); >>> - ret = 0; >>> - printf(" OK\n"); >>> + ksft_test_result_pass("%s dmabuf sync succeeded\n", __func__); >>> + return; >>> + >>> out: >>> - if (p) >>> - munmap(p, ONE_MEG); >>> - if (importer_fd >= 0) >>> - close(importer_fd); >>> - if (dmabuf_fd >= 0) >>> - close(dmabuf_fd); >>> - if (heap_fd >= 0) >>> - close(heap_fd); >>> + ksft_test_result_fail("%s dmabuf sync failed\n", __func__); >>> + munmap(p, ONE_MEG); >>> + close(importer_fd); >>> >>> - return ret; >>> +close_and_return: >>> + close(dmabuf_fd); >>> + close(heap_fd); >>> } >>> >>> -static int test_alloc_zeroed(char *heap_name, size_t size) >>> +static void test_alloc_zeroed(char *heap_name, size_t size) >>> { >>> int heap_fd = -1, dmabuf_fd[32]; >>> - int i, j, ret; >>> + int i, j, k, ret; >>> void *p = NULL; >>> char *c; >>> >>> - printf(" Testing alloced %ldk buffers are zeroed: ", size / 1024); >>> + ksft_print_msg("Testing alloced %ldk buffers are zeroed:\n", size / 1024); >>> heap_fd = dmabuf_heap_open(heap_name); >>> - if (heap_fd < 0) >>> - return -1; >>> >>> /* Allocate and fill a bunch of buffers */ >>> for (i = 0; i < 32; i++) { >>> ret = dmabuf_heap_alloc(heap_fd, size, 0, &dmabuf_fd[i]); >>> - if (ret < 0) { >>> - printf("FAIL (Allocation (%i) failed)\n", i); >>> - goto out; >>> + if (ret) { >>> + ksft_test_result_fail("FAIL (Allocation (%i) failed) %d\n", i, ret); >>> + goto close_and_return; >>> } >>> + >>> /* mmap and fill with simple pattern */ >>> p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, dmabuf_fd[i], 0); >>> if (p == MAP_FAILED) { >>> - printf("FAIL (mmap() failed!)\n"); >>> - ret = -1; >>> - goto out; >>> + ksft_test_result_fail("FAIL (mmap() failed!): %s\n", strerror(errno)); >>> + goto close_and_return; >>> } >>> + >>> dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_START); >>> memset(p, 0xff, size); >>> dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_END); >>> @@ -251,48 +236,47 @@ static int test_alloc_zeroed(char *heap_name, size_t size) >>> /* close them all */ >>> for (i = 0; i < 32; i++) >>> close(dmabuf_fd[i]); >>> + ksft_test_result_pass("Allocate and fill a bunch of buffers\n"); >>> >>> /* Allocate and validate all buffers are zeroed */ >>> for (i = 0; i < 32; i++) { >>> ret = dmabuf_heap_alloc(heap_fd, size, 0, &dmabuf_fd[i]); >>> if (ret < 0) { >>> - printf("FAIL (Allocation (%i) failed)\n", i); >>> - goto out; >>> + ksft_test_result_fail("FAIL (Allocation (%i) failed) %d\n", i, ret); >>> + goto close_and_return; >>> } >>> >>> /* mmap and validate everything is zero */ >>> p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, dmabuf_fd[i], 0); >>> if (p == MAP_FAILED) { >>> - printf("FAIL (mmap() failed!)\n"); >>> - ret = -1; >>> - goto out; >>> + ksft_test_result_fail("FAIL (mmap() failed!): %s\n", strerror(errno)); >>> + goto close_and_return; >>> } >>> + >>> dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_START); >>> c = (char *)p; >>> for (j = 0; j < size; j++) { >>> if (c[j] != 0) { >>> - printf("FAIL (Allocated buffer not zeroed @ %i)\n", j); >>> - break; >>> + ksft_print_msg("FAIL (Allocated buffer not zeroed @ %i)\n", j); >>> + dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_END); >>> + munmap(p, size); >>> + goto out; >>> } >>> } >>> dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_END); >>> munmap(p, size); >>> } >>> - /* close them all */ >>> - for (i = 0; i < 32; i++) >>> - close(dmabuf_fd[i]); >>> - >>> - close(heap_fd); >>> - printf("OK\n"); >>> - return 0; >>> >>> out: >>> - while (i > 0) { >>> - close(dmabuf_fd[i]); >>> - i--; >>> - } >>> + ksft_test_result(i == 32, "Allocate and validate all buffers are zeroed\n"); >>> + >>> +close_and_return: >>> + /* close them all */ >>> + for (k = 0; k < i; k++) >>> + close(dmabuf_fd[k]); >>> + >>> close(heap_fd); >>> - return ret; >>> + return; >>> } >>> >>> /* Test the ioctl version compatibility w/ a smaller structure then expected */ >>> @@ -360,126 +344,97 @@ static int dmabuf_heap_alloc_newer(int fd, size_t len, unsigned int flags, >>> return ret; >>> } >>> >>> -static int test_alloc_compat(char *heap_name) >>> +static void test_alloc_compat(char *heap_name) >>> { >>> - int heap_fd = -1, dmabuf_fd = -1; >>> - int ret; >>> + int ret, heap_fd = -1, dmabuf_fd = -1; >>> >>> heap_fd = dmabuf_heap_open(heap_name); >>> - if (heap_fd < 0) >>> - return -1; >>> >>> - printf(" Testing (theoretical)older alloc compat: "); >>> + ksft_print_msg("Testing (theoretical) older alloc compat:\n"); >>> ret = dmabuf_heap_alloc_older(heap_fd, ONE_MEG, 0, &dmabuf_fd); >>> - if (ret) { >>> - printf("FAIL (Older compat allocation failed!)\n"); >>> - ret = -1; >>> - goto out; >>> - } >>> - close(dmabuf_fd); >>> - printf("OK\n"); >>> + if (dmabuf_fd >= 0) >>> + close(dmabuf_fd); >>> + ksft_test_result(!ret, "dmabuf_heap_alloc_older\n"); >>> >>> - printf(" Testing (theoretical)newer alloc compat: "); >>> + ksft_print_msg("Testing (theoretical) newer alloc compat:\n"); >>> ret = dmabuf_heap_alloc_newer(heap_fd, ONE_MEG, 0, &dmabuf_fd); >>> - if (ret) { >>> - printf("FAIL (Newer compat allocation failed!)\n"); >>> - ret = -1; >>> - goto out; >>> - } >>> - printf("OK\n"); >>> -out: >>> if (dmabuf_fd >= 0) >>> close(dmabuf_fd); >>> - if (heap_fd >= 0) >>> - close(heap_fd); >>> + ksft_test_result(!ret, "dmabuf_heap_alloc_newer\n"); >>> >>> - return ret; >>> + close(heap_fd); >>> } >>> >>> -static int test_alloc_errors(char *heap_name) >>> +static void test_alloc_errors(char *heap_name) >>> { >>> int heap_fd = -1, dmabuf_fd = -1; >>> int ret; >>> >>> heap_fd = dmabuf_heap_open(heap_name); >>> - if (heap_fd < 0) >>> - return -1; >>> >>> - printf(" Testing expected error cases: "); >>> + ksft_print_msg("Testing expected error cases:\n"); >>> ret = dmabuf_heap_alloc(0, ONE_MEG, 0x111111, &dmabuf_fd); >>> - if (!ret) { >>> - printf("FAIL (Did not see expected error (invalid fd)!)\n"); >>> - ret = -1; >>> - goto out; >>> - } >>> + ksft_test_result(ret, "Error expected on invalid fd %d\n", ret); >>> >>> ret = dmabuf_heap_alloc(heap_fd, ONE_MEG, 0x111111, &dmabuf_fd); >>> - if (!ret) { >>> - printf("FAIL (Did not see expected error (invalid heap flags)!)\n"); >>> - ret = -1; >>> - goto out; >>> - } >>> + ksft_test_result(ret, "Error expected on invalid heap flags %d\n", ret); >>> >>> ret = dmabuf_heap_alloc_fdflags(heap_fd, ONE_MEG, >>> ~(O_RDWR | O_CLOEXEC), 0, &dmabuf_fd); >>> - if (!ret) { >>> - printf("FAIL (Did not see expected error (invalid fd flags)!)\n"); >>> - ret = -1; >>> - goto out; >>> - } >>> + ksft_test_result(ret, "Error expected on invalid heap flags %d\n", ret); >>> >>> - printf("OK\n"); >>> - ret = 0; >>> -out: >>> if (dmabuf_fd >= 0) >>> close(dmabuf_fd); >>> - if (heap_fd >= 0) >>> - close(heap_fd); >>> + close(heap_fd); >>> +} >>> >>> - return ret; >>> +static int numer_of_heaps(void) >>> +{ >>> + DIR *d = opendir(DEVPATH); >>> + struct dirent *dir; >>> + int heaps = 0; >>> + >>> + while ((dir = readdir(d))) { >>> + if (!strncmp(dir->d_name, ".", 2)) >>> + continue; >>> + if (!strncmp(dir->d_name, "..", 3)) >>> + continue; >>> + heaps++; >>> + } >>> + >>> + return heaps; >>> } >>> >>> int main(void) >>> { >>> - DIR *d; >>> struct dirent *dir; >>> - int ret = -1; >>> + DIR *d; >>> + >>> + ksft_print_header(); >>> >>> d = opendir(DEVPATH); >>> if (!d) { >>> - printf("No %s directory?\n", DEVPATH); >>> - return -1; >>> + ksft_print_msg("No %s directory?\n", DEVPATH); >>> + return KSFT_SKIP; >>> } >>> >>> - while ((dir = readdir(d)) != NULL) { >>> + ksft_set_plan(11 * numer_of_heaps()); >>> + >>> + while ((dir = readdir(d))) { >>> if (!strncmp(dir->d_name, ".", 2)) >>> continue; >>> if (!strncmp(dir->d_name, "..", 3)) >>> continue; >>> >>> - printf("Testing heap: %s\n", dir->d_name); >>> - printf("=======================================\n"); >>> - ret = test_alloc_and_import(dir->d_name); >>> - if (ret) >>> - break; >>> - >>> - ret = test_alloc_zeroed(dir->d_name, 4 * 1024); >>> - if (ret) >>> - break; >>> - >>> - ret = test_alloc_zeroed(dir->d_name, ONE_MEG); >>> - if (ret) >>> - break; >>> - >>> - ret = test_alloc_compat(dir->d_name); >>> - if (ret) >>> - break; >>> - >>> - ret = test_alloc_errors(dir->d_name); >>> - if (ret) >>> - break; >>> + ksft_print_msg("Testing heap: %s\n", dir->d_name); >>> + ksft_print_msg("=======================================\n"); >>> + test_alloc_and_import(dir->d_name); >>> + test_alloc_zeroed(dir->d_name, 4 * 1024); >>> + test_alloc_zeroed(dir->d_name, ONE_MEG); >>> + test_alloc_compat(dir->d_name); >>> + test_alloc_errors(dir->d_name); >>> } >>> closedir(d); >>> >>> - return ret; >>> + ksft_finished(); >>> } >> > -- BR, Muhammad Usama Anjum