Ejemplo n.º 1
0
static void test_prot(void *p, int prot)
{
	int r, w;

	verbose_printf("Reading..");
	r = test_read(p);
	verbose_printf("%d\n", r);
	verbose_printf("Writing..");
	w = test_write(p, RANDOM_CONSTANT);
	verbose_printf("%d\n", w);

	if (prot & PROT_READ) {
		if (r != 0)
			FAIL("read failed on mmap(prot=%x)", prot);
	} else {
		if (r != -1)
			FAIL("read succeeded on mmap(prot=%x)", prot);
	}

	if (prot & PROT_WRITE) {
		switch (w) {
		case -1:
			FAIL("write failed on mmap(prot=%x)", prot);
			break;
		case 0:
			break;
		case 1:
			FAIL("write mismatch on mmap(prot=%x)", prot);
			break;
		default:
			TEST_BUG();
		}
	} else {
		switch (w) {
		case -1:
			break;
		case 0:
			FAIL("write succeeded on mmap(prot=%x)", prot);
			break;
		case 1:
			FAIL("write mismatch on mmap(prot=%x)", prot);
			break;
		default:
			TEST_BUG();
		}
	}
}
Ejemplo n.º 2
0
static int path_parent_len(const char *path)
{
    const char *p = strrchr(path, '/');

    if (!p)
        TEST_BUG();
    if (p == path)
        return 1;
    else
        return p - path;
}
Ejemplo n.º 3
0
void BugsTestMainLayer::menuCallback(CCObject* pSender)
{
    CCMenuItemFont* pItem = (CCMenuItemFont*)pSender;
    int nIndex = pItem->getZOrder() - kItemTagBasic;

    switch (nIndex)
    {
    case 0:
        TEST_BUG(350);
        break;
    case 1:
        TEST_BUG(422);
        break;
    case 2:
        TEST_BUG(458);
        break;
    case 3:
        TEST_BUG(624);
        break;
    case 4:
        TEST_BUG(886);
        break;
    case 5:
        TEST_BUG(899);
        break;
    case 6:
        TEST_BUG(914);
        break;
    case 7:
        TEST_BUG(1159);
        break;
    case 8:
        TEST_BUG(1174);
        break;
    case 9:
        TEST_BUG(ParticleBufOverflow);
        break;
    default:
        break;
    }
}
Ejemplo n.º 4
0
static void compare_node(const void *fdt1, int offset1,
			 const void *fdt2, int offset2)
{
	int err;
	char path1[PATH_MAX], path2[PATH_MAX];

	CHECK(fdt_get_path(fdt1, offset1, path1, sizeof(path1)));
	CHECK(fdt_get_path(fdt2, offset2, path2, sizeof(path2)));

	if (!streq(path1, path2))
		TEST_BUG("Path mismatch %s vs. %s\n", path1, path2);

	verbose_printf("Checking %s\n", path1);

	compare_properties(fdt1, offset1, fdt2, offset2);
	compare_properties(fdt2, offset2, fdt1, offset1);

	compare_subnodes(fdt1, offset1, fdt2, offset2, 1);
	compare_subnodes(fdt2, offset2, fdt1, offset1, 0);
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
	long hpage_size;
	int fd;
	void *p;
	unsigned long straddle_addr;

	test_init(argc, argv);

	hpage_size = check_hugepagesize();

	if (sizeof(void *) <= 4)
		TEST_BUG("64-bit only");

	if (hpage_size > FOURGB)
		CONFIG("Huge page size too large");

	fd = hugetlbfs_unlinked_fd();
	if (fd < 0)
		FAIL("hugetlbfs_unlinked_fd()");

	straddle_addr = FOURGB - hpage_size;

	/* We first try to get the mapping without MAP_FIXED */
	verbose_printf("Mapping without MAP_FIXED at %lx...", straddle_addr);
	p = mmap((void *)straddle_addr, 2*hpage_size, PROT_READ|PROT_WRITE,
		 MAP_SHARED, fd, 0);
	if (p == (void *)straddle_addr) {
		/* These tests irrelevant if we didn't get the
		 * straddle address */
		verbose_printf("done\n");

		if (test_addr_huge(p) != 1)
			FAIL("Mapped address is not hugepage");

		if (test_addr_huge(p + hpage_size) != 1)
			FAIL("Mapped address is not hugepage");

		verbose_printf("Clearing below 4GB...");
		memset(p, 0, hpage_size);
		verbose_printf("done\n");

		verbose_printf("Clearing above 4GB...");
		memset(p + hpage_size, 0, hpage_size);
		verbose_printf("done\n");
	} else {
		verbose_printf("got %p instead, never mind\n", p);
		munmap(p, 2*hpage_size);
	}

	verbose_printf("Mapping with MAP_FIXED at %lx...", straddle_addr);
	p = mmap((void *)straddle_addr, 2*hpage_size, PROT_READ|PROT_WRITE,
		 MAP_SHARED|MAP_FIXED, fd, 0);
	if (p == MAP_FAILED) {
		/* this area crosses last low slice and first high slice */
		unsigned long below_start = FOURGB - 256L*1024*1024;
		unsigned long above_end = 1024L*1024*1024*1024;
		if (range_is_mapped(below_start, above_end) == 1) {
			verbose_printf("region (4G-256M)-1T is not free\n");
			verbose_printf("mmap() failed: %s\n", strerror(errno));
			PASS_INCONCLUSIVE();
		} else
			FAIL("mmap() FIXED failed: %s\n", strerror(errno));
	}
	if (p != (void *)straddle_addr) {
		verbose_printf("got %p instead\n", p);
		FAIL("Wrong address with MAP_FIXED");
	}
	verbose_printf("done\n");

	if (test_addr_huge(p) != 1)
		FAIL("Mapped address is not hugepage");

	if (test_addr_huge(p + hpage_size) != 1)
		FAIL("Mapped address is not hugepage");

	verbose_printf("Clearing below 4GB...");
	memset(p, 0, hpage_size);
	verbose_printf("done\n");

	verbose_printf("Clearing above 4GB...");
	memset(p + hpage_size, 0, hpage_size);
	verbose_printf("done\n");

	verbose_printf("Tested above 4GB\n");

	PASS();
}
Ejemplo n.º 6
0
int main(int argc, char *argv[])
{
	long hpage_size;
	int fd;
	void *p;
	unsigned long straddle_addr;

	test_init(argc, argv);

	hpage_size = check_hugepagesize();

	if (sizeof(void *) <= 4)
		TEST_BUG("64-bit only");

	if (hpage_size > FOURGB)
		CONFIG("Huge page size too large");

	fd = hugetlbfs_unlinked_fd();
	if (fd < 0)
		FAIL("hugetlbfs_unlinked_fd()");

	straddle_addr = FOURGB - hpage_size;

	/* We first try to get the mapping without MAP_FIXED */
	verbose_printf("Mapping without MAP_FIXED at %lx...", straddle_addr);
	p = mmap((void *)straddle_addr, 2*hpage_size, PROT_READ|PROT_WRITE,
		 MAP_SHARED, fd, 0);
	if (p == (void *)straddle_addr) {
		/* These tests irrelevant if we didn't get the
		 * straddle address */
		verbose_printf("done\n");

		if (test_addr_huge(p) != 1)
			FAIL("Mapped address is not hugepage");

		if (test_addr_huge(p + hpage_size) != 1)
			FAIL("Mapped address is not hugepage");

		verbose_printf("Clearing below 4GB...");
		memset(p, 0, hpage_size);
		verbose_printf("done\n");

		verbose_printf("Clearing above 4GB...");
		memset(p + hpage_size, 0, hpage_size);
		verbose_printf("done\n");
	} else {
		verbose_printf("got %p instead, never mind\n", p);
		munmap(p, 2*hpage_size);
	}

	verbose_printf("Mapping with MAP_FIXED at %lx...", straddle_addr);
	p = mmap((void *)straddle_addr, 2*hpage_size, PROT_READ|PROT_WRITE,
		 MAP_SHARED|MAP_FIXED, fd, 0);
	if (p == MAP_FAILED)
		FAIL("mmap() FIXED: %s", strerror(errno));
	if (p != (void *)straddle_addr) {
		verbose_printf("got %p instead\n", p);
		FAIL("Wrong address with MAP_FIXED");
	}
	verbose_printf("done\n");

	if (test_addr_huge(p) != 1)
		FAIL("Mapped address is not hugepage");

	if (test_addr_huge(p + hpage_size) != 1)
		FAIL("Mapped address is not hugepage");

	verbose_printf("Clearing below 4GB...");
	memset(p, 0, hpage_size);
	verbose_printf("done\n");

	verbose_printf("Clearing above 4GB...");
	memset(p + hpage_size, 0, hpage_size);
	verbose_printf("done\n");

	verbose_printf("Tested above 4GB\n");

	PASS();
}