mirror of
https://github.com/fadden/nulib2.git
synced 2025-01-14 01:29:43 +00:00
Fix test-twirl
The test was expecting the order of threads not to change, which was reasonable until we started throwing fake threads at it with the recent change to "mask dataless". We now employ a hack that reorders the CRCs from data-class threads so that the data fork's CRC always comes first. Not a tremendously robust solution, but it'll do.
This commit is contained in:
parent
bbeb9eaf90
commit
51af83986c
@ -184,6 +184,7 @@ CRCList* GatherCRCs(NuArchive* pArchive)
|
||||
goto bail;
|
||||
}
|
||||
|
||||
int rsrcCrcIdx = -1;
|
||||
for (i = 0; i < (int)NuRecordGetNumThreads(pRecord); i++) {
|
||||
pThread = NuGetThread(pRecord, i);
|
||||
if (pThread->thThreadClass == kNuThreadClassData) {
|
||||
@ -194,7 +195,30 @@ CRCList* GatherCRCs(NuArchive* pArchive)
|
||||
goto bail;
|
||||
}
|
||||
|
||||
pEntries[crcIdx++] = pThread->thThreadCRC;
|
||||
/*
|
||||
* Ensure that the data fork CRC comes first. Otherwise
|
||||
* we can fail if it gets rearranged. This is only a
|
||||
* problem for GSHK-created archives that don't have
|
||||
* threads for every fork, so "mask dataless" is create
|
||||
* fake entries.
|
||||
*
|
||||
* The correct way to do this is to store a tuple
|
||||
* { thread-kind, crc }, but that's more work.
|
||||
*/
|
||||
if (pThread->thThreadKind == kNuThreadKindRsrcFork) {
|
||||
rsrcCrcIdx = crcIdx;
|
||||
}
|
||||
|
||||
if (pThread->thThreadKind == kNuThreadKindDataFork &&
|
||||
rsrcCrcIdx != -1)
|
||||
{
|
||||
/* this is the data fork, we've already seen the
|
||||
resource fork; swap entries */
|
||||
pEntries[crcIdx++] = pEntries[rsrcCrcIdx];
|
||||
pEntries[rsrcCrcIdx] = pThread->thThreadCRC;
|
||||
} else {
|
||||
pEntries[crcIdx++] = pThread->thThreadCRC;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user