Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libi386 Add a test on the maximum number of slots.



details:   https://anonhg.NetBSD.org/src/rev/a7cd2c3604c3
branches:  trunk
changeset: 931312:a7cd2c3604c3
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Apr 26 12:13:10 2020 +0000

description:
Add a test on the maximum number of slots.

diffstat:

 tests/lib/libi386/t_user_ldt.c |  13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diffs (34 lines):

diff -r 548fa4adcdad -r a7cd2c3604c3 tests/lib/libi386/t_user_ldt.c
--- a/tests/lib/libi386/t_user_ldt.c    Sun Apr 26 11:56:38 2020 +0000
+++ b/tests/lib/libi386/t_user_ldt.c    Sun Apr 26 12:13:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_user_ldt.c,v 1.1 2020/04/19 13:22:58 maxv Exp $      */
+/*     $NetBSD: t_user_ldt.c,v 1.2 2020/04/26 12:13:10 maxv Exp $      */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -42,6 +42,10 @@
 #include <machine/sysarch.h>
 #include <machine/vmparam.h>
 
+#define _LOCORE /* XXX a bit of a hack, but whatever */
+#include <machine/gdt.h>
+#undef _LOCORE
+
 #include <atf-c.h>
 
 static uint8_t *ldt_base;
@@ -166,6 +170,13 @@
                ATF_REQUIRE_EQ(i386_set_ldt(256, &desc, 1), -1);
                ATF_REQUIRE_EQ(errno, EACCES);
        }
+
+       /* Check the slot limit. */
+       build_desc(&desc, ldt_base, PAGE_SIZE, SDT_MEMRW, SEL_UPL, 1, 0);
+       ATF_REQUIRE_EQ(i386_set_ldt(MAX_USERLDT_SLOTS-1, &desc, 1),
+           MAX_USERLDT_SLOTS-1);
+       ATF_REQUIRE_EQ(i386_set_ldt(MAX_USERLDT_SLOTS, &desc, 1), -1);
+       ATF_REQUIRE_EQ(errno, EINVAL);
 }
 
 /* -------------------------------------------------------------------------- */



Home | Main Index | Thread Index | Old Index