Esempio n. 1
0
    void runTest()
    {
        beginTest ("TextDiff");

        testDiff (String::empty, String::empty);
        testDiff ("x", String::empty);
        testDiff (String::empty, "x");
        testDiff ("x", "x");
        testDiff ("x", "y");
        testDiff ("xxx", "x");
        testDiff ("x", "xxx");

        for (int i = 5000; --i >= 0;)
        {
            String s (createString());
            testDiff (s, createString());
            testDiff (s + createString(), s + createString());
        }
    }
Esempio n. 2
0
    void runTest() override
    {
        beginTest ("TextDiff");

        Random r = getRandom();

        testDiff (String::empty, String::empty);
        testDiff ("x", String::empty);
        testDiff (String::empty, "x");
        testDiff ("x", "x");
        testDiff ("x", "y");
        testDiff ("xxx", "x");
        testDiff ("x", "xxx");

        for (int i = 1000; --i >= 0;)
        {
            String s (createString (r));
            testDiff (s, createString (r));
            testDiff (s + createString (r), s + createString (r));
        }
    }
Esempio n. 3
0
int main(int argc, char **argv) {
	SceUID vpl = sceKernelCreateVpl("vpl", PSP_MEMORY_PARTITION_USER, 0, 0x10000, NULL);
	void *data;

	testTryAlloc("More than free", vpl, 0xFFE1, 1);
	testTryAlloc("0 bytes", vpl, 0, 1);
	testTryAlloc("1 byte", vpl, 1, 1);
	testTryAlloc("-1 bytes", vpl, -1, 1);
	testTryAlloc("16 bytes", vpl, 16, 1);
	testTryAlloc("8 bytes", vpl, 8, 1);

	// Crashes.
	//testTryAlloc("Into NULL", vpl, 8, 0);

	testTryAlloc("Most remaining", vpl, 0xFF00, 1);
	testTryAlloc("More than remaining", vpl, 0xA1, 1);
	testTryAlloc("All remaining", vpl, 0xA0, 1);
	testTryAlloc("All remaining - 7", vpl, 0xA0 - 7, 1);
	testTryAlloc("All remaining - 8", vpl, 0xA0 - 8, 1);
	testTryAlloc("1 byte (none left)", vpl, 1, 1);

	sceKernelDeleteVpl(vpl);

	testTryAlloc("NULL", 0, 0x100, 1);
	testTryAlloc("NULL with invalid", 0, 0, 0);
	testTryAlloc("Invalid", 0xDEADBEEF, 0x100, 1);
	testTryAlloc("Deleted", vpl, 0x100, 1);
	flushschedf();

	testDiff();

	u32 attrs[] = {PSP_VPL_ATTR_FIFO, PSP_VPL_ATTR_PRIORITY, PSP_VPL_ATTR_SMALLEST, PSP_VPL_ATTR_HIGHMEM};
	int i;
	for (i = 0; i < sizeof(attrs) / sizeof(attrs[0]); ++i) {
		schedf("Attr %x:\n", attrs[i]);
		testTryAllocThread("  Alloc 0x20 of 0x00/0xE0", attrs[i], 0x20, 0xE0 - 0x08);
		testTryAllocThread("  Alloc 0x20 of 0x20/0xE0", attrs[i], 0x20, 0xE0 - 0x08 - (0x20 + 0x08));
		testTryAllocThread("  Alloc 0x20 of 0x40/0xE0", attrs[i], 0x20, 0xE0 - 0x08 - (0x20 + 0x08) * 2);
		schedf("\n");
	}

	BASIC_SCHED_TEST("Zero",
		result = sceKernelTryAllocateVpl(vpl1, 0, &data);
	);
int main(int argc, char **argv) {
	SceUID vpl = sceKernelCreateVpl("vpl", PSP_MEMORY_PARTITION_USER, 0, 0x10000, NULL);
	void *data;

	schedf("No timeout:\n");
	testAlloc("  More than free", vpl, 0xFFE1, 1);
	testAlloc("  0 bytes", vpl, 0, 1);
	testAlloc("  1 byte", vpl, 1, 1);
	testAlloc("  -1 bytes", vpl, -1, 1);
	testAlloc("  16 bytes", vpl, 16, 1);
	testAlloc("  8 bytes", vpl, 8, 1);

	schedf("\nWith timeout:\n");
	testAllocTimeout("  More than free", vpl, 0xFFE1, 500, 1);
	testAllocTimeout("  0 bytes", vpl, 0, 500, 1);
	testAllocTimeout("  1 byte", vpl, 1, 500, 1);
	testAllocTimeout("  -1 bytes", vpl, -1, 500, 1);
	testAllocTimeout("  16 bytes", vpl, 16, 500, 1);
	testAllocTimeout("  8 bytes", vpl, 8, 500, 1);
	
	schedf("\nErrors:\n");
	// Crashes.
	//testAllocTimeout("Into NULL", vpl, 8, 500, 0);
	testAllocTimeout("  Into NULL", vpl, 0xFFE0, 500, 0);

	testAllocTimeout("  Most remaining", vpl, 0xFF00, 500, 1);
	testAllocTimeout("  More than remaining", vpl, 0xA1, 500, 1);
	testAllocTimeout("  All remaining", vpl, 0x68, 500, 1);
	testAllocTimeout("  All remaining - 7", vpl, 0x68 - 7, 500, 1);
	testAllocTimeout("  All remaining - 8", vpl, 0x68 - 8, 500, 1);
	testAllocTimeout("  1 byte (none left)", vpl, 1, 500, 1);
	testAllocTimeout("  1 byte (none left, 0 timeout)", vpl, 1, 0, 1);

	sceKernelDeleteVpl(vpl);

	testAllocTimeout("  NULL", 0, 0x100, 500, 1);
	testAllocTimeout("  NULL with invalid", 0, 0, 500, 0);
	testAllocTimeout("  Invalid", 0xDEADBEEF, 0x100, 500, 1);
	testAllocTimeout("  Deleted", vpl, 0x100, 500, 1);
	schedf("\n");

	testDiff();

	u32 attrs[] = {PSP_VPL_ATTR_FIFO, PSP_VPL_ATTR_PRIORITY, PSP_VPL_ATTR_SMALLEST, PSP_VPL_ATTR_HIGHMEM};
	int i;
	for (i = 0; i < sizeof(attrs) / sizeof(attrs[0]); ++i) {
		schedf("Attr %x:\n", attrs[i]);
		testAllocThread("  Alloc 0x10 of 0x00/0xE0", attrs[i], 0x20, 0xE0 - 0x08);
		testAllocThread("  Alloc 0x10 of 0x20/0xE0", attrs[i], 0x20, 0xE0 - 0x08 - (0x20 + 0x08));
		testAllocThread("  Alloc 0x10 of 0x40/0xE0", attrs[i], 0x20, 0xE0 - 0x08 - (0x20 + 0x08) * 2);
		schedf("\n");
	}
	flushschedf();

	SceUID deleteThread = CREATE_SIMPLE_THREAD(deleteMeFunc);
	vpl = sceKernelCreateVpl("vpl", PSP_MEMORY_PARTITION_USER, 0, 0x10000, NULL);
	sceKernelAllocateVpl(vpl, 0x10000 - 0x20 - 0x08, &data, NULL);
	sceKernelStartThread(deleteThread, sizeof(SceUID), &vpl);
	sceKernelDeleteVpl(vpl);
	flushschedf();

	unsigned int timeout;
	BASIC_SCHED_TEST("Zero",
		timeout = 500;
		result = sceKernelAllocateVpl(vpl1, 0, &data, &timeout);
	);