From patchwork Tue Dec 15 06:49:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joerg Vehlow X-Patchwork-Id: 1416300 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=jv-coder.de Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=jv-coder.de header.i=@jv-coder.de header.a=rsa-sha256 header.s=dkim header.b=jJ2SxQ1s; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cw84X0WCZz9s0b for ; Tue, 15 Dec 2020 17:49:15 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 59A263C2E12 for ; Tue, 15 Dec 2020 07:49:13 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id 9DD833C2A02 for ; Tue, 15 Dec 2020 07:49:11 +0100 (CET) Received: from mail.jv-coder.de (mail.jv-coder.de [5.9.79.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id B4432600840 for ; Tue, 15 Dec 2020 07:49:10 +0100 (CET) Received: from ubuntu.localdomain (unknown [188.192.1.224]) by mail.jv-coder.de (Postfix) with ESMTPSA id 2E5DE9F616; Tue, 15 Dec 2020 06:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jv-coder.de; s=dkim; t=1608014949; bh=d7cps9hnfNI4CJCecwKLZDmuyHZFPdFCgriYiB6nSy8=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=jJ2SxQ1sUBOtSBp6ivyjmcfo73F7tDc8w3Tu8veK+PiZuJ+O7IRegVTG8RCSGGj4C pbtff4xVSZR6fCpIOAiAY2TvR1RxKTx0drNwN1N+4DbiLf86iyLVCN90RYOS91cXpC DEyic45FhGWf15vY8rrmAv6d91y4RlxfJ3MDluHQ= From: Joerg Vehlow To: ltp@lists.linux.it Date: Tue, 15 Dec 2020 07:49:02 +0100 Message-Id: <20201215064902.518801-1-lkml@jv-coder.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH] shm_open/37-1: Remove non-portable output X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Vehlow Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Joerg Vehlow This test could mess up some tools, because it wrote characters outside of the ansi character set. Since most systems expect utf-8 now, this could lead to messed up or even output. This replaces the verbatim output of the shm ames used in the test with a short description. It also replaces the no-protable characters with escape sequences and adds the missing close, if the shm was opend successfully. Signed-off-by: Joerg Vehlow --- .../conformance/interfaces/shm_open/37-1.c | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/shm_open/37-1.c b/testcases/open_posix_testsuite/conformance/interfaces/shm_open/37-1.c index 69dabd951..09b4d6657 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/shm_open/37-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/shm_open/37-1.c @@ -1,65 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0 /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * * Test that the shm_open() function sets errno = EINVAL if the shm_open() * operation is not supported for the given name. * * The supported names are implementation-defined, so the test is done for - * several differents names. The test pass for a given name if shm_open make no + * several different names. The test pass for a given name if shm_open make no * error or set errno to EINVAL. */ #include +#include #include #include #include #include #include "posixtest.h" -static char *shm_name[] = { - /* char which are in portable character set but not in portable - filename character set */ - "$#\n@\t\a,~}", - /* char which are not in portable character set (accentuated char and c - cedilla) */ - "éêîôçà", - /* some file or directory which should exist */ - "..", - "/", - "//", - "/abc", - NULL +struct test_data { + const char *desc; + const char *name; +}; + +struct test_data testdata[] = { + { + "char which are in portable character set, " + "but not in portable filename character set", + "$#\n@\t\a,~}" + }, + { + "chars which are not in portable character set " + "(accentuated char and c cedilla)", + "\xe9\xea\xee\xf4\xe7\xe0" + }, + { "parent directory", ".." }, + { "root directory", "/" }, + { "double slash", "//" }, + { "non-existent directory", "/abc" } }; int main(void) { - int fd, i = 0, result = PTS_PASS; + unsigned int i; + int fd, result = PTS_PASS; - while (shm_name[i]) { + for (i = 0; i < ARRAY_SIZE(testdata); i++) { fflush(stderr); - printf("Name: '%s'\n", shm_name[i]); + printf("Test: %s\n", testdata[i].desc); fflush(stdout); - fd = shm_open(shm_name[i], O_RDWR | O_CREAT, 0); - + fd = shm_open(testdata[i].name, O_RDWR | O_CREAT, 0); if (fd == -1 && errno == EINVAL) { printf(" OK: errno == EINVAL\n"); } else if (fd != -1) { - printf(" OK: open with success.\n"); + printf(" OK: open with success.\n"); + close(fd); } else { perror(" Unexpected error"); result = PTS_FAIL; } - shm_unlink(shm_name[i]); - - i++; + shm_unlink(testdata[i].name); } if (result == PTS_PASS)