Skip to content

Commit

Permalink
Remove some duplicated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Apr 10, 2024
1 parent 6723a13 commit 8b81f55
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
58 changes: 44 additions & 14 deletions tests/c/instruction_checks/r4000allegrex_disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ size_t strlen_null(const char *string) {
return strlen(string);
}

int strcmp_null(const char *s0, const char *s1) {
if (s0 == s1) {
return 0;
}

if (s0 == NULL) {
return 1;
}

if (s1 == NULL) {
return -1;
}

return strcmp(s0, s1);
}

typedef struct TestEntry {
uint32_t word;
const char *immOverride;
Expand Down Expand Up @@ -44,6 +60,7 @@ const TestEntry entries[] = {
{ 0x7C0410A0, NULL, "wsbh $v0, $a0" },
{ 0x7C0410E0, NULL, "wsbw $v0, $a0" },

#if 0
{ 0xBC840000, NULL, "cache IXIN, 0x0($a0)" },
{ 0xBC860000, NULL, "cache IXUN, 0x0($a0)" },
{ 0xBC880000, NULL, "cache IHIN, 0x0($a0)" },
Expand All @@ -58,6 +75,22 @@ const TestEntry entries[] = {
{ 0xBC9C0000, NULL, "cache DCDEXL, 0x0($a0)" },
{ 0xBC9E0000, NULL, "cache DF, 0x0($a0)" },
{ 0xBC9F0000, NULL, "cache DFL, 0x0($a0)" },
#else
{ 0xBC840000, NULL, "cache 0x04, 0x0($a0)" },
{ 0xBC860000, NULL, "cache 0x06, 0x0($a0)" },
{ 0xBC880000, NULL, "cache 0x08, 0x0($a0)" },
{ 0xBC8A0000, NULL, "cache 0x0A, 0x0($a0)" },
{ 0xBC8B0000, NULL, "cache 0x0B, 0x0($a0)" },
{ 0xBC940000, NULL, "cache 0x14, 0x0($a0)" },
{ 0xBC960000, NULL, "cache 0x16, 0x0($a0)" },
{ 0xBC980000, NULL, "cache 0x18, 0x0($a0)" },
{ 0xBC990000, NULL, "cache 0x19, 0x0($a0)" },
{ 0xBC9A0000, NULL, "cache 0x1A, 0x0($a0)" },
{ 0xBC9B0000, NULL, "cache 0x1B, 0x0($a0)" },
{ 0xBC9C0000, NULL, "cache 0x1C, 0x0($a0)" },
{ 0xBC9E0000, NULL, "cache 0x1E, 0x0($a0)" },
{ 0xBC9F0000, NULL, "cache 0x1F, 0x0($a0)" },
#endif

{ 0x0000000F, NULL, "sync" },
{ 0xC0820000, NULL, "ll $v0, 0x0($a0)" },
Expand All @@ -67,14 +100,9 @@ const TestEntry entries[] = {
{ 0xBC810000, NULL, "cache 0x01, 0x0($a0)" },
{ 0xBC820000, NULL, "cache 0x02, 0x0($a0)" },
{ 0xBC830000, NULL, "cache 0x03, 0x0($a0)" },
{ 0xBC840000, NULL, "cache IXIN, 0x0($a0)" },
{ 0xBC850000, NULL, "cache 0x05, 0x0($a0)" },
{ 0xBC860000, NULL, "cache IXUN, 0x0($a0)" },
{ 0xBC870000, NULL, "cache 0x07, 0x0($a0)" },
{ 0xBC880000, NULL, "cache IHIN, 0x0($a0)" },
{ 0xBC890000, NULL, "cache 0x09, 0x0($a0)" },
{ 0xBC8A0000, NULL, "cache IF, 0x0($a0)" },
{ 0xBC8B0000, NULL, "cache IFL, 0x0($a0)" },
{ 0xBC8C0000, NULL, "cache 0x0C, 0x0($a0)" },
{ 0xBC8D0000, NULL, "cache 0x0D, 0x0($a0)" },
{ 0xBC8E0000, NULL, "cache 0x0E, 0x0($a0)" },
Expand All @@ -83,18 +111,9 @@ const TestEntry entries[] = {
{ 0xBC910000, NULL, "cache 0x11, 0x0($a0)" },
{ 0xBC920000, NULL, "cache 0x12, 0x0($a0)" },
{ 0xBC930000, NULL, "cache 0x13, 0x0($a0)" },
{ 0xBC940000, NULL, "cache DXWBIN, 0x0($a0)" },
{ 0xBC950000, NULL, "cache 0x15, 0x0($a0)" },
{ 0xBC960000, NULL, "cache DXUN, 0x0($a0)" },
{ 0xBC970000, NULL, "cache 0x17, 0x0($a0)" },
{ 0xBC980000, NULL, "cache DCDEX, 0x0($a0)" },
{ 0xBC990000, NULL, "cache DHIN, 0x0($a0)" },
{ 0xBC9A0000, NULL, "cache DHWB, 0x0($a0)" },
{ 0xBC9B0000, NULL, "cache DHWBIN, 0x0($a0)" },
{ 0xBC9C0000, NULL, "cache DCDEXL, 0x0($a0)" },
{ 0xBC9D0000, NULL, "cache 0x1D, 0x0($a0)" },
{ 0xBC9E0000, NULL, "cache DF, 0x0($a0)" },
{ 0xBC9F0000, NULL, "cache DFL, 0x0($a0)" },

{ 0x70000000, NULL, "sleep" },
{ 0x000002A8, NULL, "mfie $v0" },
Expand All @@ -106,6 +125,17 @@ int main() {
int errorCount = 0;
size_t i;

for (i = 0; i < ARRAY_COUNT(entries); i++) {
size_t j;

for (j = i+1; j < ARRAY_COUNT(entries); j++) {
if ((entries[i].word == entries[j].word) && (strcmp_null(entries[i].immOverride, entries[j].immOverride) == 0)) {
fprintf(stderr, "Duplicated entry. Word: '0x%08X'. immOverride: '%s'\n", entries[i].word, entries[i].immOverride);
errorCount++;
}
}
}

for (i = 0; i < ARRAY_COUNT(entries); i++) {
const TestEntry *entry = &entries[i];
RabbitizerInstruction instr;
Expand Down
2 changes: 1 addition & 1 deletion tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ const TestEntry entries[] = {
{ 0xF4800040, NULL, "svl.q C000, 0x40($a0)" },
{ 0xF4800042, NULL, "svr.q C000, 0x40($a0)" },

// According to the manual, bit 1 should be zero. The compiler handles it fine, but objdump ignores this bit, do idk
// According to the manual, bit 1 should be zero. The compiler handles it fine, but objdump ignores this bit, so idk
{ 0xD8800043, NULL, NULL },
{ 0xD8810043, NULL, NULL },
{ 0xD8820043, NULL, NULL },
Expand Down

0 comments on commit 8b81f55

Please sign in to comment.