Example #1
0
static uintptr_t
simpleHandlerFunction(struct OMRPortLibrary *portLibrary, uint32_t gpType, void *gpInfo, void *handler_arg)
{
	OMRPORT_ACCESS_FROM_OMRPORT(portLibrary);
	simpleHandlerInfo *info = (simpleHandlerInfo *)handler_arg;
	const char *testName = info->testName;
	uintptr_t rc;

	portTestEnv->log("calling omrdump_create with filename: %s\n", info->coreFileName);

#if defined(J9ZOS390)
	rc = omrdump_create(info->coreFileName, "IEATDUMP", NULL);
#else
	rc = omrdump_create(info->coreFileName, NULL, NULL);
#endif

	if (rc == 0) {
		uintptr_t verifyFileRC = 99;

		portTestEnv->log("omrdump_create claims to have written a core file to: %s\n", info->coreFileName);
		verifyFileRC = verifyFileExists(PORTTEST_ERROR_ARGS, info->coreFileName);
		if (verifyFileRC == 0) {
			removeDump(OMRPORTLIB, info->coreFileName, testName);
		}
	} else {
		outputErrorMessage(PORTTEST_ERROR_ARGS, "omrdump_create returned: %u, with filename: %s", rc, info->coreFileName);
	}

	return OMRPORT_SIG_EXCEPTION_RETURN;
}
Example #2
0
/**
 * Call omrdump_create() without passing in core file name. This does not actually test that a core file was actually created.
 */
TEST(PortDumpTest, dump_test_create_dump_with_NO_name)
{
	OMRPORT_ACCESS_FROM_OMRPORT(portTestEnv->getPortLibrary());
	const char *testName = "omrdump_test_create_dump_with_NO_name";
	uintptr_t rc = 99;
	char coreFileName[EsMaxPath];
	BOOLEAN doFileVerification = FALSE;
#if defined(AIXPPC)
	struct vario myvar;
	int sys_parmRC;
#endif

	reportTestEntry(OMRPORTLIB, testName);

	coreFileName[0] = '\0';

#if 0
	/* try out a NULL test (turns out this crashes) */
	rc = omrdump_create(NULL, NULL, NULL); /* this crashes */
#endif

	/* try out a more sane NULL test */
	portTestEnv->log("calling omrdump_create with empty filename\n");

#if defined(J9ZOS390)
	rc = omrdump_create(coreFileName, "IEATDUMP", NULL);
#else
	rc = omrdump_create(coreFileName, NULL, NULL);
#endif

	if (rc == 0) {
		uintptr_t verifyFileRC = 99;

		portTestEnv->log("omrdump_create claims to have written a core file to: %s\n", coreFileName);


#if defined(AIXPPC)
		/* We defer to fork abort on AIX machines that don't have "Enable full CORE dump" enabled in smit,
		 * in which case omrdump_create will not return the filename.
		 * So, only check for a specific filename if we are getting full core dumps */
		sys_parmRC = sys_parm(SYSP_GET, SYSP_V_FULLCORE, &myvar);

		if ((sys_parmRC == 0) && (myvar.v.v_fullcore.value == 1)) {

			doFileVerification = TRUE;
		}
#else /* defined(AIXPPC) */
		doFileVerification = TRUE;
#endif /* defined(AIXPPC) */
		if (doFileVerification) {
			verifyFileRC = verifyFileExists(PORTTEST_ERROR_ARGS, coreFileName);
			if (verifyFileRC == 0) {
				removeDump(OMRPORTLIB, coreFileName, testName);
			}
		}
	} else {
		outputErrorMessage(PORTTEST_ERROR_ARGS, "omrdump_create returned: %u, with filename: %s", rc, coreFileName);
	}
	reportTestExit(OMRPORTLIB, testName);
}
bool_t createRainbowTableUsingIni(const char * hashName,
				  const char * prefix,
				  const char * rule,
				  const char * iniFilename) {
	bool_t ret = FALSE;
	const char * keys[] = {	"dictionary_name",
				"rainbow_chain_length",
				"entires_in_hash_table",
				"bucket_block_length" };
	const char * values[sizeof(keys) / sizeof(*keys)] = {0};
	const uint_t numKeys = sizeof(keys) / sizeof(*keys);
	char * iniContent = NULL;
	
	/* Parse INI file */
	CHECK(verifyFileExists(iniFilename));
	iniContent = readEntireTextFile(iniFilename);
	CHECK(NULL != iniContent);
	CHECK(parseIni(iniContent, keys, values, numKeys));
	
	/* Invoke rainbow table creation */
	ret = createRainbowTable(hashName, prefix, rule, values[0], values[1], values[2], values[3]);

LBL_ERROR:
	FREE(iniContent);
	return ret;
}
Example #4
0
void makeFileSize(const char * path, off_t size) {
	verifyFileExists(path);

	off_t currentFileSize = getFileSize(path);
	off_t dataToAdd = 0;
	if (currentFileSize < size) {
		dataToAdd = size - currentFileSize;
	}
	else if (currentFileSize > size) {
		int fd = open(path, O_TRUNC | O_RDWR);
		VERIFY_ERRNO(-1 != fd, "Failed to open the file for truncating: %s\n", ECFailedToOpenForTruncate);
		close(fd);
		dataToAdd = size;
	}
	else {
		// Note - File is just the right size, we don't need to do anythig
	}

	if (size != 0) {
		appendRandomDataToFile(path, dataToAdd);
	}
}
Example #5
0
/**
 * Test omrdump_create(), this time passing in core file name
 * Verify that the returned core file name actually exists.
 *
 * @note this only tests IEATDUMP generation on z/OS
 */
TEST(PortDumpTest, dump_test_create_dump_with_name)
{
	OMRPORT_ACCESS_FROM_OMRPORT(portTestEnv->getPortLibrary());
	const char *testName = "omrdump_test_create_dump_with_name";
	uintptr_t rc = 99;
	char buff[EsMaxPath];
	char *coreFileName = NULL;

	reportTestEntry(OMRPORTLIB, testName);

#if defined(J9ZOS390)
	coreFileName = atoe_getcwd(buff, EsMaxPath);
#else
	coreFileName = getcwd(buff, EsMaxPath);
#endif

	strncat(coreFileName, "/", EsMaxPath);	/* make sure the directory ends with a slash */
	strncat(coreFileName, testName, EsMaxPath);

	portTestEnv->log("calling omrdump_create with filename: %s\n", coreFileName);
#if !defined(J9ZOS390)
	rc = omrdump_create(coreFileName, NULL, NULL);
#else
	rc = omrdump_create(coreFileName, "IEATDUMP", NULL);
#endif

	if (rc == 0) {
		uintptr_t verifyFileRC = 99;

		portTestEnv->log("omrdump_create claims to have written a core file to: %s\n", coreFileName);
		verifyFileRC = verifyFileExists(PORTTEST_ERROR_ARGS, coreFileName);
		if (verifyFileRC == 0) {
			removeDump(OMRPORTLIB, coreFileName, testName);
		}
	} else {
		outputErrorMessage(PORTTEST_ERROR_ARGS, "omrdump_create returned: %u, with filename: %s\n", rc, coreFileName);
	}
	reportTestExit(OMRPORTLIB, testName);
}