From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yh0-f49.google.com (mail-yh0-f49.google.com [209.85.213.49]) by dpdk.org (Postfix) with ESMTP id 7B8DFAFD0 for ; Mon, 23 Jun 2014 23:17:22 +0200 (CEST) Received: by mail-yh0-f49.google.com with SMTP id f73so5533487yha.36 for ; Mon, 23 Jun 2014 14:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=Q0UGdxk2b3v/89obp0kpAR37XaJfgxB4zdy2+zhJgL8=; b=S8+AWXlBJNbEPM207jDKeOkEQ75N9Z+0hY16smY5iJcApv1MY0KgGLxRhMO7sfFVPn FiqOi117SXIGNWFKS93jun4hnzIiID3v0vep1GCgsZRWGuDf0wnAs7Q2NJMpEdn2aOjr meKyeqiWodPLf5Z5552KlrDmzZeDXqmbajNVbnOlnrmTwxxFHNk8SG5SHp0IUMg+EFQY cYGM0PRuyHX9vS54jZq3PsAX9F9DU1XL8YAVu5EAcBjNOWAk46YL5JhMSAMmEs0dxsD1 0xrZOjCORWf9MrwTY6MAgzlc7J8YlXXaeISmb5HXnjMNKyJdiK72LSO29JFLf1/vCO4P 2S5A== X-Received: by 10.236.66.139 with SMTP id h11mr39720964yhd.30.1403558260351; Mon, 23 Jun 2014 14:17:40 -0700 (PDT) Received: from localhost.localdomain ([69.80.69.242]) by mx.google.com with ESMTPSA id m25sm31531405yhc.12.2014.06.23.14.17.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jun 2014 14:17:39 -0700 (PDT) From: Robert Sanford To: dev@dpdk.org Date: Mon, 23 Jun 2014 17:17:10 -0400 Message-Id: <1403558230-40042-3-git-send-email-rsanford2@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1400245141-10938-1-git-send-email-rsanford2@gmail.com> References: <1400245141-10938-1-git-send-email-rsanford2@gmail.com> Subject: [dpdk-dev] [PATCH v3 2/2] malloc: fix malloc and free linear complexity X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jun 2014 21:17:23 -0000 Fix typos and false assumptions in malloc unit tests. Without enhancements to lib rte_malloc, malloc autotest fails every second (2nd) run. With enhancements, malloc autotest fails in function test_multi_alloc_statistics, because we compare the wrong sets of statistics. Signed-off-by: Robert Sanford --- app/test/test_malloc.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/test/test_malloc.c b/app/test/test_malloc.c index 3c38383..bf27eff 100644 --- a/app/test/test_malloc.c +++ b/app/test/test_malloc.c @@ -66,7 +66,7 @@ * ====== * * Allocate some dynamic memory from heap (3 areas). Check that areas - * don't overlap an that alignment constraints match. This test is + * don't overlap and that alignment constraints match. This test is * done many times on different lcores simultaneously. */ @@ -313,9 +313,9 @@ test_big_alloc(void) rte_malloc_get_socket_stats(socket,&post_stats); /* Check statistics reported are correct */ - /* Allocation increase, cannot be the same as before big allocation */ - if (post_stats.heap_totalsz_bytes == pre_stats.heap_totalsz_bytes) { - printf("Malloc statistics are incorrect - heap_totalz_bytes\n"); + /* Allocation may increase, or may be the same as before big allocation */ + if (post_stats.heap_totalsz_bytes < pre_stats.heap_totalsz_bytes) { + printf("Malloc statistics are incorrect - heap_totalsz_bytes\n"); return -1; } /* Check that allocated size adds up correctly */ @@ -336,7 +336,8 @@ test_big_alloc(void) return -1; } /* New blocks now available - just allocated 1 but also 1 new free */ - if(post_stats.free_count != pre_stats.free_count ) { + if (post_stats.free_count != pre_stats.free_count && + post_stats.free_count != pre_stats.free_count - 1) { printf("Malloc statistics are incorrect - free_count\n"); return -1; } @@ -425,7 +426,7 @@ test_multi_alloc_statistics(void) } /* Make sure that we didn't touch our greatest chunk: 2 * 11M) */ - if (second_stats.greatest_free_size != pre_stats.greatest_free_size) { + if (post_stats.greatest_free_size != pre_stats.greatest_free_size) { printf("Incorrect heap statistics: Greatest free size \n"); return -1; } @@ -1036,11 +1037,11 @@ test_malloc(void) ret = test_multi_alloc_statistics(); if (ret < 0) { - printf("test_muti_alloc_statistics() failed\n"); + printf("test_multi_alloc_statistics() failed\n"); return ret; } else - printf("test_muti_alloc_statistics() passed\n"); + printf("test_multi_alloc_statistics() passed\n"); return 0; } -- 1.7.1