mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:43:57 +00:00
[vm/test] Remove checked-in binaries from MachO test.
Instead of using checked-in binaries in snapshot_utils_test.cc, write out the binaries manually and check the written binaries. TEST=vm/cc/CanDetectMachOFiles Issue: https://github.com/dart-lang/.allstar/issues/159 Change-Id: I024ecac2084cfaef6bf8fe2a7cecceb9ae5d8de9 Cq-Include-Trybots: luci.dart.try:vm-kernel-mac-release-arm64-try,vm-kernel-mac-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255460 Reviewed-by: Alexander Thomas <athom@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
This commit is contained in:
parent
dca2025821
commit
00bd7ff339
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "bin/snapshot_utils.h"
|
||||
#include "bin/dartutils.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/test_utils.h"
|
||||
#include "platform/assert.h"
|
||||
|
@ -12,22 +13,58 @@
|
|||
namespace dart {
|
||||
|
||||
#if defined(DART_TARGET_OS_MACOS)
|
||||
TEST_CASE(CanDetectMachOFiles) {
|
||||
const char* kMachO32BitLittleEndianFilename =
|
||||
bin::test::GetFileName("runtime/tests/vm/data/macho_32bit_little_endian");
|
||||
const char* kMachO64BitLittleEndianFilename =
|
||||
bin::test::GetFileName("runtime/tests/vm/data/macho_64bit_little_endian");
|
||||
const char* kMachO32BitBigEndianFilename =
|
||||
bin::test::GetFileName("runtime/tests/vm/data/macho_32bit_big_endian");
|
||||
const char* kMachO64BitBigEndianFilename =
|
||||
bin::test::GetFileName("runtime/tests/vm/data/macho_64bit_big_endian");
|
||||
|
||||
EXPECT(
|
||||
bin::Snapshot::IsMachOFormattedBinary(kMachO32BitLittleEndianFilename));
|
||||
EXPECT(
|
||||
bin::Snapshot::IsMachOFormattedBinary(kMachO64BitLittleEndianFilename));
|
||||
EXPECT(bin::Snapshot::IsMachOFormattedBinary(kMachO32BitBigEndianFilename));
|
||||
EXPECT(bin::Snapshot::IsMachOFormattedBinary(kMachO64BitBigEndianFilename));
|
||||
static const unsigned char kMachO32BitLittleEndianHeader[] = {
|
||||
0xce, 0xfa, 0xed, 0xfe, 0x07, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static const unsigned char kMachO32BitBigEndianHeader[] = {
|
||||
0xfe, 0xed, 0xfa, 0xce, 0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static const unsigned char kMachO64BitLittleEndianHeader[] = {
|
||||
0xcf, 0xfa, 0xed, 0xfe, 0x07, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static const unsigned char kMachO64BitBigEndianHeader[] = {
|
||||
0xfe, 0xed, 0xfa, 0xcf, 0x01, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static const struct {
|
||||
const char* filename;
|
||||
const unsigned char* contents;
|
||||
size_t contents_size;
|
||||
} kTestcases[] = {
|
||||
{"macho_32bit_little_endian", kMachO32BitLittleEndianHeader,
|
||||
ARRAY_SIZE(kMachO32BitLittleEndianHeader)},
|
||||
{"macho_32bit_big_endian", kMachO32BitBigEndianHeader,
|
||||
ARRAY_SIZE(kMachO32BitBigEndianHeader)},
|
||||
{"macho_64bit_little_endian", kMachO64BitLittleEndianHeader,
|
||||
ARRAY_SIZE(kMachO64BitLittleEndianHeader)},
|
||||
{"macho_64bit_big_endian", kMachO64BitBigEndianHeader,
|
||||
ARRAY_SIZE(kMachO64BitBigEndianHeader)},
|
||||
};
|
||||
|
||||
TEST_CASE(CanDetectMachOFiles) {
|
||||
for (uintptr_t i = 0; i < ARRAY_SIZE(kTestcases); i++) {
|
||||
const auto& testcase = kTestcases[i];
|
||||
auto* const file =
|
||||
bin::DartUtils::OpenFile(testcase.filename, /*write=*/true);
|
||||
bin::DartUtils::WriteFile(testcase.contents, testcase.contents_size, file);
|
||||
bin::DartUtils::CloseFile(file);
|
||||
|
||||
EXPECT(bin::Snapshot::IsMachOFormattedBinary(testcase.filename));
|
||||
|
||||
EXPECT(bin::File::Delete(nullptr, testcase.filename));
|
||||
}
|
||||
|
||||
const char* kFilename =
|
||||
bin::test::GetFileName("runtime/bin/snapshot_utils_test.cc");
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue