Skip to content

Commit

Permalink
zeroed sector unscramble with lba 10350, removed dic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
superg committed Dec 13, 2022
1 parent 9424d09 commit 37960c6
Show file tree
Hide file tree
Showing 48 changed files with 2 additions and 49 deletions.
4 changes: 2 additions & 2 deletions scrambler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ bool Scrambler::Descramble(uint8_t *sector, int32_t *lba, uint32_t size) const
{
bool unscrambled = false;

// not enough data to analyze
if(size < sizeof(Sector::sync) + sizeof(Sector::header))
// zeroed or not enough data to analyze
if(is_zeroed(sector, size) || size < sizeof(Sector::sync) + sizeof(Sector::header))
return unscrambled;

// unscramble sector
Expand Down
47 changes: 0 additions & 47 deletions tests/tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,51 +167,6 @@ bool test_unscramble()
}


bool test_unscramble_dic()
{
bool success = true;

Scrambler scrambler;

std::set<std::filesystem::path> test_files;
for(auto const &f : std::filesystem::directory_iterator("unscramble/dic"))
if(f.is_regular_file())
test_files.insert(f.path());

for(auto const &f : test_files)
{
std::cout << fmt::format("descramble DIC: {}... ", f.filename().string()) << std::flush;

std::vector<uint8_t> sector = read_vector(f);

auto tokens = tokenize(f.filename().string(), ".", nullptr);
if(tokens.size() == 3)
{
int32_t lba = 0;
int32_t *lba_ptr = &lba;
if(tokens[1] == "null")
lba_ptr = nullptr;
else
*lba_ptr = std::stol(tokens[1]);
bool scrambled = tokens[2] == "pass";
bool unscrambled = scrambler.DescrambleDIC(sector.data(), lba_ptr, sector.size());

if(unscrambled == scrambled)
std::cout << "success";
else
{
std::cout << "failure";
success = false;
}
}

std::cout << std::endl;
}

return success;
}



int main(int argc, char *argv[])
{
Expand All @@ -223,8 +178,6 @@ int main(int argc, char *argv[])
std::cout << std::endl;
success |= (int)!test_unscramble();
std::cout << std::endl;
success |= (int)!test_unscramble_dic();
std::cout << std::endl;

return success;
}
Binary file added tests/unscramble/46_zeroed_sector.10350.fail
Binary file not shown.
Binary file removed tests/unscramble/dic/01_invalid_sync.0.fail
Binary file not shown.
Binary file removed tests/unscramble/dic/02_not_enough_data.0.fail
Binary file not shown.
Binary file removed tests/unscramble/dic/03_mode0_zeroed_data.0.pass
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed tests/unscramble/dic/08_mode1.0.pass
Binary file not shown.
Binary file removed tests/unscramble/dic/09_mode2.0.pass
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed tests/unscramble/dic/23_msf_mismatch_mode1.42.pass
Binary file not shown.
Binary file removed tests/unscramble/dic/24_msf_mismatch_mode2.42.pass
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed tests/unscramble/dic/38_no_msf_mode1.null.pass
Binary file not shown.
Binary file removed tests/unscramble/dic/39_no_msf_mode2.null.pass
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 37960c6

Please sign in to comment.