From patchwork Mon Oct 19 06:13:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 1384009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=sionneau.net Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=sionneau.net header.i=@sionneau.net header.a=rsa-sha1 header.s=selectormx3 header.b=xgLKv+gO; dkim-atps=neutral Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (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 4CF5zP45v3z9sSC for ; Mon, 19 Oct 2020 17:13:21 +1100 (AEDT) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id A881D10166; Mon, 19 Oct 2020 08:13:18 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from mx3.sionneau.net (mx3.sionneau.net [163.172.183.177]) by helium.openadk.org (Postfix) with ESMTPS id 0CD2910166 for ; Mon, 19 Oct 2020 08:13:17 +0200 (CEST) Received: from mx3.sionneau.net (localhost [127.0.0.1]) by mx3.sionneau.net. (OpenSMTPD) with ESMTP id c72f580a for ; Mon, 19 Oct 2020 06:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=simple; d=sionneau.net; h=from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; s=selectormx3; bh=XgozlsO25NcW1bApsjJw1h+I4i0=; b=xgLKv+gOClLkA YkAnboj/Ds1SPqFcqX/QG6J0fXXfJV2O4ZIn0EFltpDublPLJG/wb5/O+B1ODLQm chAhvUKDsz0Apnes6sJRtPjcUmFT1gG8UMMYa38Dn8WuRi29OeoXVB8Kf/WY7kj0 D4plyqwPKVN6bUwmadrvZU11TZ8B58= DomainKey-Signature: a=rsa-sha1; c=simple; d=sionneau.net; h=from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; q=dns; s=selectormx3; b=CgywFA7XrytoSX/km+fY/c+qoK5pVKpFInczLy/ zuKp7wL4y31nfVzaJZwlmyLeAjCjw0TvOGi/Kmth/qc0Yfy+FX4wsyYGVufG7Hoe 7f5FqYSyW96srw73X08RkvfSsjxaO+C+qV15LBicK3Q5Ji7zgBxZrzKZ3fAAj8Yd Afic= Received: by mx3.sionneau.net (OpenSMTPD) with ESMTPSA id 3f564015 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO); Mon, 19 Oct 2020 06:13:16 +0000 (UTC) From: yann@sionneau.net To: devel@uclibc-ng.org Date: Mon, 19 Oct 2020 08:13:00 +0200 Message-Id: <20201019061300.1377576-1-yann@sionneau.net> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [uclibc-ng-devel] [PATCH] misc: add test for hasmntopt() option matching X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" From: Yann Sionneau Signed-off-by: Yann Sionneau --- test/misc/tst-hasmntopt.c | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/misc/tst-hasmntopt.c diff --git a/test/misc/tst-hasmntopt.c b/test/misc/tst-hasmntopt.c new file mode 100644 index 0000000..17655bd --- /dev/null +++ b/test/misc/tst-hasmntopt.c @@ -0,0 +1,47 @@ +/* Copyright (C) 2020 by Yann Sionneau */ + +#include +#include +#include +#include + +static int +do_test (void) +{ + char *res; + struct mntent m; + + /* check that "ro" does not match "erROr" */ + m.mnt_opts = "error"; + res = hasmntopt (&m, MNTOPT_RO); + if (res != NULL) { + puts ("error: hasmntopt() picked up non existing option"); + exit (1); + } + + /* check that "ro" does not match "remount-ro" */ + m.mnt_opts = "rw,relatime,errors=remount-ro"; + res = hasmntopt (&m, MNTOPT_RO); + if (res != NULL) { + puts ("error: hasmntopt() picked up non existing option"); + exit (1); + } + + /* check that "ro" does match "ro" */ + m.mnt_opts = "noatime,ro"; + res = hasmntopt (&m, MNTOPT_RO); + if (res == NULL) { + puts ("error: hasmntopt() did not pick up an existing option"); + exit (1); + } + + if (strncmp(res, "ro", 2) != 0) { + puts ("error: hasmntopt() did not return a pointer to corresponding option"); + exit (1); + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c"