From patchwork Wed Sep 5 13:47:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Lund X-Patchwork-Id: 966399 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gomspace.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YQYNw3pM"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4254m904f5z9s3Z for ; Wed, 5 Sep 2018 23:48:25 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ZBAY1agRd0QK58thuNggUB46JiJuGocP5UR6aMEs/Lw=; b=YQYNw3pMuHojm4 ipjCcfekVCffNiZrQ5Bq36Mn+x/aBjXRYGE2f1R5DSejyFPz2sEpD30UOW0Nv/RzgMQ6iL6oKB0Zz LEzEfZmI1waQhY/Tn6HV//WQpcOS1ZA9Kq11BINT2E1jahi0DzlKs9pIX9DQrtg+Sfn6erAxU1q8n IxfnKs/ueO5xQoSQEJg6FbpJ6nJjqsR+JtwVJUph+CuvH4wUX/ZFKxDDFKCwebVH8j0hiXNDHvYiM +ZCVyhCEsHF69eAPNc/WTxHppFv5Qp4OnLWo5ALav5GVJCa46ZxNQjYXwMrpYdMwUQeEApxv01eAJ LP4p8pn21Mg2/jWX+GHQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxYAL-00076F-FO; Wed, 05 Sep 2018 13:48:17 +0000 Received: from martinlund.org ([173.255.130.145] helo=slmp-550-86.slc.westdc.net) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fxYAH-0006ae-Us for linux-mtd@lists.infradead.org; Wed, 05 Sep 2018 13:48:15 +0000 Received: from [79.171.149.172] (port=34584 helo=quark.gomspace.lan) by slmp-550-86.slc.westdc.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1fxYA4-004Lj4-Qo for linux-mtd@lists.infradead.org; Wed, 05 Sep 2018 07:48:01 -0600 From: Martin Lund To: linux-mtd@lists.infradead.org Subject: [PATCH v2 mtd-utils] ubi-tests: io_paral: Fix error handling of update_volume() Date: Wed, 5 Sep 2018 15:47:38 +0200 Message-Id: <20180905134738.3461-1-malu@gomspace.com> X-Mailer: git-send-email 2.18.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - slmp-550-86.slc.westdc.net X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - gomspace.com X-Get-Message-Sender-Via: slmp-550-86.slc.westdc.net: authenticated_id: martin.lund+keep-it-simple.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: slmp-550-86.slc.westdc.net: martin.lund@keep-it-simple.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180905_064814_056413_930EDEF6 X-CRM114-Status: UNSURE ( 9.86 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.9 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.9 SPF_FAIL SPF: sender does not match SPF record (fail) [SPF failed: Please see http://www.openspf.org/Why?s=mfrom; id=malu%40gomspace.com; ip=173.255.130.145; r=bombadil.infradead.org] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The io_paral test returns success even in case it throws e.g. the following error message: [io_paral] update_volume():125: written and read data are different This patch fixes so that the io_paral application returns a non-zero error code when an error is detected. --- tests/ubi-tests/io_paral.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/ubi-tests/io_paral.c b/tests/ubi-tests/io_paral.c index b2b462e..da24b1b 100644 --- a/tests/ubi-tests/io_paral.c +++ b/tests/ubi-tests/io_paral.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -149,22 +150,22 @@ static void *update_thread(void *ptr) if (ret) { failed("ubi_rmvol"); errorm("cannot remove volume %d", vol_id); - return NULL; + return (void *) -1; } ret = ubi_mkvol(libubi, node, &reqests[vol_id]); if (ret) { failed("ubi_mkvol"); errorm("cannot create volume %d", vol_id); - return NULL; + return (void *) -1; } } ret = update_volume(vol_id, bytes); - if (ret) - return NULL; + if (ret != 0) + return (void *) -1; } - return NULL; + return (void *) 0; } static void *write_thread(void *ptr) @@ -179,7 +180,7 @@ static void *write_thread(void *ptr) if (fd == -1) { failed("open"); errorm("cannot open \"%s\"\n", vol_node); - return NULL; + return (void *) -1; } ret = ubi_set_property(fd, UBI_VOL_PROP_DIRECT_WRITE, 1); @@ -228,12 +229,13 @@ static void *write_thread(void *ptr) } close(fd); - return NULL; + return (void *) 0; } int main(int argc, char * const argv[]) { - int i, ret; + int i, ret, error=false; + intptr_t thread_ret; pthread_t threads[THREADS_NUM]; if (initial_check(argc, argv)) @@ -301,8 +303,14 @@ int main(int argc, char * const argv[]) } } - for (i = 0; i < THREADS_NUM; i++) - pthread_join(threads[i], NULL); + for (i = 0; i < THREADS_NUM; i++) { + pthread_join(threads[i], (void **) &thread_ret); + if (thread_ret != 0) + error = true; + } + + if (error) + goto remove; for (i = 0; i <= THREADS_NUM; i++) { if (ubi_rmvol(libubi, node, i)) {