From patchwork Tue Nov 30 10:52:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1561543 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=F6xkCKHu; dkim-atps=neutral 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4J3Jw66gHMz9sWJ for ; Tue, 30 Nov 2021 21:52:54 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 5784B3C5E07 for ; Tue, 30 Nov 2021 11:52:52 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 97F983C4E59 for ; Tue, 30 Nov 2021 11:52:50 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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-4.smtp.seeweb.it (Postfix) with ESMTPS id F3BB31000930 for ; Tue, 30 Nov 2021 11:52:49 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 38AEB1FD54; Tue, 30 Nov 2021 10:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1638269569; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=FfQw9HcEXH7m6lIk+ticzzVaTJzvk+lTYqVMzb2vlh4=; b=F6xkCKHu1fYr2xzy8pTblOasz2T+b8d2t9JI9zbMc148Dac5q73PNOconbaqJA0zyOcmLJ 3qYvxeNhhxNXccFwIOPjqVpTJrGwajcI5QWknpmD23O1rnqiY8/f5U/0dKd1SV1kmhF835 cw/zQI2Ps3gLXlgTCaYKaZtN+1X80ic= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DBB2813C44; Tue, 30 Nov 2021 10:52:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4A7uLoACpmFNQgAAMHmgww (envelope-from ); Tue, 30 Nov 2021 10:52:48 +0000 To: ltp@lists.linux.it Date: Tue, 30 Nov 2021 11:52:46 +0100 Message-Id: <20211130105246.19900-1-andrea.cervesato@suse.com> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean 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-4.smtp.seeweb.it Subject: [LTP] [PATCH v2] Add common.h utilities for aiodio tests 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: , X-Patchwork-Original-From: Andrea Cervesato via ltp From: Andrea Cervesato Reply-To: Andrea Cervesato Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Andrea Cervesato --- testcases/kernel/io/ltp-aiodio/common.h | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 testcases/kernel/io/ltp-aiodio/common.h diff --git a/testcases/kernel/io/ltp-aiodio/common.h b/testcases/kernel/io/ltp-aiodio/common.h new file mode 100644 index 000000000..860abcc2a --- /dev/null +++ b/testcases/kernel/io/ltp-aiodio/common.h @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 SUSE LLC Andrea Cervesato + */ + +#ifndef AIODIO_COMMON_H__ +#define AIODIO_COMMON_H__ + +#include +#include "tst_test.h" + +static char *check_zero(char *buf, int size) +{ + char *p; + + p = buf; + + while (size > 0) { + if (*buf != 0) { + tst_res(TINFO, + "non zero buffer at buf[%lu] => 0x%02x,%02x,%02x,%02x", + buf - p, (unsigned int)buf[0], + size > 1 ? (unsigned int)buf[1] : 0, + size > 2 ? (unsigned int)buf[2] : 0, + size > 3 ? (unsigned int)buf[3] : 0); + tst_res(TINFO, "buf %p, p %p", buf, p); + return buf; + } + buf++; + size--; + } + + return 0; +} + +static void io_append(const char *path, char pattern, int flags, size_t bs, size_t bcount) +{ + int fd; + size_t i; + char *bufptr; + + bufptr = SAFE_MEMALIGN(getpagesize(), bs); + memset(bufptr, pattern, bs); + + fd = SAFE_OPEN(path, flags, 0666); + + for (i = 0; i < bcount; i++) + SAFE_WRITE(1, fd, bufptr, bs); + + free(bufptr); + SAFE_CLOSE(fd); +} + +#endif /* AIODIO_COMMON_H__ */ \ No newline at end of file