예제 #1
0
    def run(self):
        with sleeper.run() as guinea:
            total_length = self.length * self.value.size()
            total_offset = self.offset * self.value.size()

            address = proctal_cli.allocate(guinea.pid(),
                                           total_offset + total_length)

            proctal_cli.write(guinea.pid(),
                              address,
                              self.type,
                              self.value,
                              array=self.offset + self.length)

            start_address = address
            start_address.add_address_offset(total_offset)
            stop_address = start_address.clone()
            stop_address.add_address_offset(total_length)

            searcher = proctal_cli.search(guinea.pid(),
                                          self.type,
                                          address_start=start_address,
                                          address_stop=stop_address,
                                          eq=test.value)

            found = 0

            for match in searcher.match_iterator():
                if self.value.cmp(match.value) != 0:
                    searcher.stop()
                    raise UnexpectedMatchValue(match.value, self.value)

                if not (start_address.cmp(match.address) <= 0
                        and stop_address.cmp(match.address) > 0):
                    searcher.stop()
                    raise UnexpectedMatchAddress(start_address, stop_address,
                                                 match.address)

                found += 1

            searcher.stop()

            if self.length != found:
                raise UnexpectedTotalMatches(self.length, found)
예제 #2
0
    def run(self):
        byte_type = proctal_cli.TypeByte();
        value = proctal_cli.ValueByte(byte_type)
        value.parse_binary(b'\x42')

        with sleeper.run() as guinea:
            address = proctal_cli.allocate(guinea.pid(), self.offset + self.length)
            address.add_address_offset(self.offset)

            proctal_cli.write(guinea.pid(), address, byte_type, value, array=self.length)

            start_address = address
            stop_address = start_address.clone()
            stop_address.add_address_offset(self.length)

            dumper = proctal_cli.dump(
                guinea.pid(),
                address_start=start_address,
                address_stop=stop_address)

            found = 0

            for match in dumper.byte_iterator():
                byte = proctal_cli.ValueByte(byte_type)
                byte.parse_binary(match)

                if value.cmp(byte) != 0:
                    dumper.stop()
                    raise UnexpectedMatchValue(value, byte)

                found += 1

            dumper.stop()

            if self.length != found:
                raise UnexpectedTotalMatches(self.length, found)
예제 #3
0
def start(test):
    with sleeper.run() as guinea:
        total_size = int(test.value.size() * test.length)

        address = proctal_cli.allocate(guinea.pid(), str(total_size))

        proctal_cli.write(guinea.pid(),
                          address,
                          test.type,
                          test.value,
                          array=test.length)

        searcher = proctal_cli.search(guinea.pid(), test.type, eq=test.value)

        start_address = address
        end_address = start_address.clone()
        end_address.add_address_offset(total_size)
        found = 0

        for match in searcher.match_iterator():
            if test.value.cmp(match.value) != 0:
                searcher.stop()
                raise UnexpectedMatchValue(test.value, match.value)

            if not (start_address.cmp(match.address) <= 0
                    and end_address.cmp(match.address) > 0):
                searcher.stop()
                raise UnexpectedMatchAddress(start_address, end_address,
                                             match.address)

            found += 1

        searcher.stop()

        if test.length != found:
            raise UnexpectedTotalMatches(test.length, found)
예제 #4
0
            try:
                writer.write_value(self.value)
                writer.stop()

                reader = proctal_cli.read(guinea.pid(), address, self.type)

                try:
                    value = reader.next_value()

                    if self.value.cmp(value) != 0:
                        raise Error("Expected {expected} but got {found}.".format(expected=self.value, found=value))
                finally:
                    reader.stop()
            finally:
                writer.stop()
        finally:
            proctal_cli.deallocate(guinea.pid(), address)

int32 = proctal_cli.TypeInteger(32);
int32_test_val = proctal_cli.ValueInteger(int32)
int32_test_val.parse(0x0ACC23AA)

tests = [
    TestSingleValue(int32, int32_test_val)
]

with sleeper.run() as guinea:
    for test in tests:
        test.run(guinea)