From patchwork Fri Jun 12 20:25:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Richter X-Patchwork-Id: 1308509 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (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 49kC4331Lnz9sQx for ; Sat, 13 Jun 2020 06:28:51 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49kC432DHCzDr0L for ; Sat, 13 Jun 2020 06:28:51 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=erichte@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49kC0G0KyrzDqxL for ; Sat, 13 Jun 2020 06:25:33 +1000 (AEST) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05CJ3WM2067166 for ; Fri, 12 Jun 2020 16:25:32 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 31mes1bcrn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Jun 2020 16:25:32 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05CKLmDH011971 for ; Fri, 12 Jun 2020 20:25:29 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 31g2s83v1x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Jun 2020 20:25:29 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05CKPRUB58982634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jun 2020 20:25:27 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0079C11C04C; Fri, 12 Jun 2020 20:25:27 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F0A1D11C050; Fri, 12 Jun 2020 20:25:25 +0000 (GMT) Received: from ceres.ibmuc.com (unknown [9.163.59.202]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Jun 2020 20:25:25 +0000 (GMT) From: Eric Richter To: skiboot@lists.ozlabs.org Date: Fri, 12 Jun 2020 15:25:02 -0500 Message-Id: <20200612202514.15032-9-erichte@linux.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200612202514.15032-1-erichte@linux.ibm.com> References: <20200612202514.15032-1-erichte@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-12_16:2020-06-12, 2020-06-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=826 suspectscore=3 cotscore=-2147483648 spamscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006110174 Subject: [Skiboot] [PATCH v5 08/20] secvar/test: update API tests for new secvar struct X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nayna@linux.ibm.com Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" From: Eric Richter This patch adjusts the API unit tests to use the secvar struct rather than the old secvar_node. Where applicable, some manual allocations have also been replaced with the util functions. Signed-off-by: Eric Richter --- libstb/secvar/test/secvar-test-enqueue.c | 6 +++--- libstb/secvar/test/secvar-test-getvar.c | 21 +++++-------------- libstb/secvar/test/secvar-test-nextvar.c | 26 ++++++------------------ 3 files changed, 14 insertions(+), 39 deletions(-) diff --git a/libstb/secvar/test/secvar-test-enqueue.c b/libstb/secvar/test/secvar-test-enqueue.c index 61c22d16..b4b2c140 100644 --- a/libstb/secvar/test/secvar-test-enqueue.c +++ b/libstb/secvar/test/secvar-test-enqueue.c @@ -16,7 +16,7 @@ int run_test(void) { int64_t rc; - struct secvar_node *node; + struct secvar *var; char key[1024] = {0}; uint64_t data_size = 128; @@ -106,8 +106,8 @@ int run_test(void) rc = secvar_enqueue(key, 4, data, data_size); ASSERT(rc == OPAL_SUCCESS); ASSERT(list_length(&update_bank) == 3); // should not increase - node = list_tail(&update_bank, struct secvar_node, link); - ASSERT(!memcmp(node->var->key, key, 4)) // should be at end + var = list_tail(&update_bank, struct secvar, link); + ASSERT(!memcmp(var->key, key, 4)) // should be at end // Unstage the variable update rc = secvar_enqueue(key, 4, NULL, 0); diff --git a/libstb/secvar/test/secvar-test-getvar.c b/libstb/secvar/test/secvar-test-getvar.c index 53885ea1..a2e06681 100644 --- a/libstb/secvar/test/secvar-test-getvar.c +++ b/libstb/secvar/test/secvar-test-getvar.c @@ -14,32 +14,25 @@ int run_test(void) { int64_t rc; - uint64_t size = 4; + uint64_t size; char *temp = zalloc(100); char key[1024] = {0}; - struct secvar_node *node = zalloc(sizeof(struct secvar_node)); - struct secvar *var = zalloc(sizeof(struct secvar) + 1024); // over-allocate for now, this should be rewritten + struct secvar *var; size_t data_size = sizeof("foobar"); char *data = zalloc(data_size); uint64_t key_len = 4; memcpy(data, "foobar", data_size); - memcpy(key, "test", 4); // List should be empty at start - rc = secvar_get(key, key_len, data, &data_size); + rc = secvar_get(key, key_len, temp, &size); ASSERT(rc == OPAL_EMPTY); ASSERT(list_length(&variable_bank) == 0); // Manually add variables, and check get_variable call - var->key_len = key_len; - memcpy(var->key, key, key_len); - var->data_size = data_size; - memcpy(var->data, data, data_size); - - node->var = var; - list_add_tail(&variable_bank, &node->link); + var = new_secvar(key, key_len, data, data_size, 0); + list_add_tail(&variable_bank, &var->link); ASSERT(list_length(&variable_bank) == 1); @@ -88,10 +81,6 @@ int run_test(void) ASSERT(rc == OPAL_RESOURCE); secvar_ready = 1; - list_del(&node->link); - - free(var); - free(node); free(data); free(temp); diff --git a/libstb/secvar/test/secvar-test-nextvar.c b/libstb/secvar/test/secvar-test-nextvar.c index 0b3dea45..dcd9e9d5 100644 --- a/libstb/secvar/test/secvar-test-nextvar.c +++ b/libstb/secvar/test/secvar-test-nextvar.c @@ -10,37 +10,23 @@ int run_test(void) int64_t rc; struct secvar *tmpvar; - struct secvar_node *tmpnode; char key[1024] = {0}; uint64_t key_len = 16; - // Load up the bank with some variables. // If these fail, we have bigger issues. ASSERT(list_length(&variable_bank) == 0); - tmpvar = zalloc(sizeof(struct secvar) + 6); - tmpnode = zalloc(sizeof(struct secvar_node)); - memcpy(tmpvar->key, "test1", 6); // ascii w/ null - tmpvar->key_len = 6; - tmpnode->var = tmpvar; - list_add_tail(&variable_bank, &tmpnode->link); + tmpvar = new_secvar("test1", 6, NULL, 0, 0); + list_add_tail(&variable_bank, &tmpvar->link); ASSERT(list_length(&variable_bank) == 1); - tmpvar = zalloc(sizeof(struct secvar) + 5); - tmpnode = zalloc(sizeof(struct secvar_node)); - memcpy(tmpvar->key, "test2", 5); // ascii w/o null - tmpvar->key_len = 5; - tmpnode->var = tmpvar; - list_add_tail(&variable_bank, &tmpnode->link); + tmpvar = new_secvar("test2", 5, NULL, 0, 0); // ascii w/o null + list_add_tail(&variable_bank, &tmpvar->link); ASSERT(list_length(&variable_bank) == 2); - tmpvar = zalloc(sizeof(struct secvar) + 5*2); - tmpnode = zalloc(sizeof(struct secvar_node)); - memcpy(tmpvar->key, L"test3", 5*2); // wide char "unicode" - tmpvar->key_len = 10; - tmpnode->var = tmpvar; - list_add_tail(&variable_bank, &tmpnode->link); + tmpvar = new_secvar((const char*) L"test3", 5*2, NULL, 0, 0); // wide char "unicode" + list_add_tail(&variable_bank, &tmpvar->link); ASSERT(list_length(&variable_bank) == 3); // Test sequential nexts