From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Hildenbrand Subject: [PATCH kvm-unit-tests 9/9] s390x: add test for (v)malloc Date: Wed, 10 Jan 2018 22:53:48 +0100 Message-ID: <20180110215348.315-10-david@redhat.com> References: <20180110215348.315-1-david@redhat.com> Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Huth , Christian Borntraeger , Cornelia Huck , David Hildenbrand To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:46550 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752518AbeAJVyS (ORCPT ); Wed, 10 Jan 2018 16:54:18 -0500 In-Reply-To: <20180110215348.315-1-david@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Let's test if basic allocation works and we get virtual addresses. Signed-off-by: David Hildenbrand --- s390x/selftest.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/s390x/selftest.c b/s390x/selftest.c index 76ed4bf..bf72d32 100644 --- a/s390x/selftest.c +++ b/s390x/selftest.c @@ -10,6 +10,7 @@ */ #include #include +#include #include static void test_fp(void) @@ -37,6 +38,21 @@ static void test_pgm_int(void) check_pgm_int_code(PGM_INT_CODE_ADDRESSING); } +static void test_malloc(void) +{ + int *tmp = malloc(sizeof(int)); + int *tmp2 = malloc(sizeof(int)); + + report("malloc: got vaddr", (uintptr_t)tmp & 0xffffffff00000000ul); + report("malloc: access works", (*tmp = 123456789)); + report("malloc: got 2nd vaddr", (uintptr_t)tmp2 & 0xffffffff00000000ul); + report("malloc: access works", (*tmp2 = 123456789)); + report("malloc: addresses differ", tmp != tmp2); + + free(tmp); + free(tmp2); +} + int main(int argc, char**argv) { report_prefix_push("selftest"); @@ -49,6 +65,7 @@ int main(int argc, char**argv) test_fp(); test_pgm_int(); + test_malloc(); return report_summary(); } -- 2.14.3