private void findTestGroups(boolean applyStruct)
			throws InvalidControlBlockException, CodeUnitInsertionException {

		Memory memory = program.getMemory();

		byte[] groupStructMagicBytes =
			getCharArrayBytes(program, PCodeTestGroupControlBlock.GROUP_CONTROL_BLOCK_MAGIC);

		testGroups = new ArrayList<>();

		AddressSet set = new AddressSet(restrictedSet);
		while (true) {

			Address startOfControlBlock = findBytes(memory, set, groupStructMagicBytes);
			if (startOfControlBlock == null) {
				break;
			}

			PCodeTestGroupControlBlock controlBlock = new PCodeTestGroupControlBlock(program,
				startOfControlBlock, groupInfoStruct, applyStruct, this);
			PCodeTestGroup testGroup = new PCodeTestGroup(controlBlock);
			testGroups.add(testGroup);

			// Remove previously searched addresses from search address set
			Address endAddr = startOfControlBlock.add(groupInfoStruct.getLength()).previous();
			AddressRange nextRange = set.getFirstRange();
			while (nextRange != null && !nextRange.contains(endAddr)) {
				set.delete(nextRange);
				nextRange = set.getFirstRange();
			}
			if (set.contains(endAddr)) {
				set = set.subtract(new AddressSet(set.getMinAddress(),
					startOfControlBlock.add(groupInfoStruct.getLength()).previous()));
			}
		}

		if (testGroups.size() == 0) {
			throw new InvalidControlBlockException(
				"P-Code test binary does not define any test groups");
		}

	}
Find Main TestInfo structure within memory and return instance of PCodeTestControlBlock
@param program
@param testFile original binary test file
@param restrictedSet a restricted set to be searched for control structures
@param cachedProgramPath program path within program file cache
@param testInfoStruct TestInfo structure definition
@param groupInfoStruct GroupInfo structure definition
@param applyStruct create structure Data within program if true
@param testResults test results storage object
@return instance of PCodeTestControlBlock
@throws InvalidControlBlockException
@throws CodeUnitInsertionException
Ghidra/Features/Base/src/main/java/ghidra/test/processors/support/PCodeTestControlBlock.java