Simplify package2 tests chain

This commit is contained in:
Dmitry Isaenko 2024-07-22 14:55:11 +03:00
parent 68a2f32c82
commit a0bdccdcf9
8 changed files with 106 additions and 146 deletions

View file

@ -0,0 +1,25 @@
package libKonogonka;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class LKonTest {
protected static KeyChainHolder keyChainHolder;
protected static final String KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"prod.keys";
protected static final String XCI_HEADER_KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"xci_header_key.txt";
protected static final String PATH_TO_FIRMWARE = "/home/loper/Projects/tempPatchesPlayground/nintendo-switch-global-firmwares/"+ File.separator+"Firmware 14.1.0";
protected static final String PATH_TO_FIRMWARES = "/home/loper/Projects/tempPatchesPlayground/nintendo-switch-global-firmwares/";
protected static final String TEMP_DIR = System.getProperty("java.io.tmpdir");
@BeforeAll
protected static void makeKeys() throws Exception{
String keyValue = new String(Files.readAllBytes(Paths.get(XCI_HEADER_KEYS_FILE_LOCATION))).trim();
Assertions.assertNotEquals(0, keyValue.length());
keyChainHolder = new KeyChainHolder(KEYS_FILE_LOCATION, keyValue);
}
}

View file

@ -23,7 +23,7 @@ public class ExtractDecompressedKip1Test {
final String KEYS_FILE_LOCATION = "FilesForTests"+ File.separator+"prod.keys";
final String XCI_HEADER_KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"xci_header_key.txt";
final String pathToFirmwares = ". . ./tempPatchesPlayground/nintendo-switch-global-firmwares";
final String pathToFirmwares = "/tmp";
private static KeyChainHolder keyChainHolder;
@ -34,8 +34,8 @@ public class ExtractDecompressedKip1Test {
makeKeys();
File firmwaresDir = new File(pathToFirmwares);
Assertions.assertNotNull(firmwaresDir);
//File[] fwDirs = new File(pathToFirmwares).listFiles((file, s) -> (s.matches("^Firmware (9\\.|[0-9][0-9]\\.).*") && ! s.endsWith(".zip")));
File[] fwDirs = new File(pathToFirmwares).listFiles((file, s) -> s.equals("Firmware 14.1.2"));
File[] fwDirs = new File(pathToFirmwares).listFiles((file, s) -> (s.matches("^Firmware (9\\.|[0-9][0-9]\\.).*") && ! s.endsWith(".zip")));
//File[] fwDirs = new File(pathToFirmwares).listFiles((file, s) -> s.equals("Firmware 14.1.2"));
for (File fw : fwDirs) {
if (fw.isFile())
@ -120,7 +120,7 @@ public class ExtractDecompressedKip1Test {
for (KIP1Provider kip1Provider : providerStream.getIni1Provider().getKip1List()){
String kip1Name = kip1Provider.getHeader().getName();
if (kip1Name.equals("FS")) {
System.out.println("Exported: "+kip1Provider.exportAsDecompressed(exportIntoFolder));
System.out.println("Exported: "+kip1Provider.exportAsDecompressed(exportIntoFolder)+"\n"+exportIntoFolder);
break;
}
}

View file

@ -1,7 +1,6 @@
package libKonogonka.package2;
import libKonogonka.Converter;
import libKonogonka.KeyChainHolder;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
@ -15,29 +14,18 @@ import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.CRC32;
import static libKonogonka.Converter.byteArrToHexStringAsLE;
/* ..::::::::::::::::::::: # 1 :::::::::::::::::::::..
* This test validates (encrypted) package2 CRC32 equality and sizes match between reference values and
* 1. package2 from RomFS exported root
* 2. package2 from RomFS exported as stand-alone file
* */
public class ExtractPackage2Test {
final String KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"prod.keys";
final String XCI_HEADER_KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"xci_header_key.txt";
final String pathToFirmware = "FilesForTests"+File.separator+"Firmware 14.1.0";
private static KeyChainHolder keyChainHolder;
final String referenceFat = "FilesForTests"+File.separator+"reference_for_system2"+File.separator+"FAT";
final String referenceExFat = "FilesForTests"+File.separator+"reference_for_system2"+File.separator+"ExFAT";
final String exportFat = System.getProperty("java.io.tmpdir")+File.separator+"Exported_FAT"+File.separator+getClass().getSimpleName();
final String exportExFat = System.getProperty("java.io.tmpdir")+File.separator+"Exported_ExFAT"+File.separator+getClass().getSimpleName();
public class ExtractPackage2Test extends LKonPackage2Test {
@DisplayName("Extract package2 test")
@Test
void testSystem2() throws Exception{
makeKeys();
String[] ncaFileNames = collectNcaFileNames();
List<NCAProvider> ncaProviders = makeNcaProviders(ncaFileNames);
@ -55,22 +43,27 @@ public class ExtractPackage2Test {
Assertions.assertNotNull(system2FatNcaProvider);
Assertions.assertNotNull(system2ExFatNcaProvider);
System.out.println("FAT " + system2FatNcaProvider.getFile().getName());
System.out.println("ExFAT " + system2ExFatNcaProvider.getFile().getName());
System.out.println("\n" +
"FAT " + system2FatNcaProvider.getFile().getName() + "\n" +
byteArrToHexStringAsLE(system2FatNcaProvider.getDecryptedKey0()) + "\n" +
byteArrToHexStringAsLE(system2FatNcaProvider.getDecryptedKey1()) + "\n" +
byteArrToHexStringAsLE(system2FatNcaProvider.getDecryptedKey2()) + "\n" +
byteArrToHexStringAsLE(system2FatNcaProvider.getDecryptedKey3()) + "\n~ ~ ~ ~ ~ ~ ~ ~ ~ ~\n" +
"ExFAT " + system2ExFatNcaProvider.getFile().getName() + "\n" +
byteArrToHexStringAsLE(system2ExFatNcaProvider.getDecryptedKey0()) + "\n" +
byteArrToHexStringAsLE(system2ExFatNcaProvider.getDecryptedKey1()) + "\n" +
byteArrToHexStringAsLE(system2ExFatNcaProvider.getDecryptedKey2()) + "\n" +
byteArrToHexStringAsLE(system2ExFatNcaProvider.getDecryptedKey3()));
Assertions.assertTrue(system2FatNcaProvider.getFile().getName().endsWith("1212c.nca"));
Assertions.assertTrue(system2ExFatNcaProvider.getFile().getName().endsWith("cc081.nca"));
testExportedFiles(system2FatNcaProvider, exportFat, referenceFat);
testExportedFiles(system2ExFatNcaProvider, exportExFat, referenceExFat);
}
void makeKeys() throws Exception{
String keyValue = new String(Files.readAllBytes(Paths.get(XCI_HEADER_KEYS_FILE_LOCATION))).trim();
Assertions.assertNotEquals(0, keyValue.length());
keyChainHolder = new KeyChainHolder(KEYS_FILE_LOCATION, keyValue);
testExportedFiles(system2FatNcaProvider, exportFat, REFERENCE_FAT);
testExportedFiles(system2ExFatNcaProvider, exportExFat, REFERENCE_EXFAT);
}
String[] collectNcaFileNames(){
File firmware = new File(pathToFirmware);
File firmware = new File(PATH_TO_FIRMWARE);
Assertions.assertTrue(firmware.exists());
String[] ncaFileNames = firmware.list((File directory, String file) -> ( ! file.endsWith(".cnmt.nca") && file.endsWith(".nca")));
Assertions.assertNotNull(ncaFileNames);
@ -79,7 +72,7 @@ public class ExtractPackage2Test {
List<NCAProvider> makeNcaProviders(String[] ncaFileNames) throws Exception{
List<NCAProvider> ncaProviders = new ArrayList<>();
for (String ncaFileName : ncaFileNames){
File nca = new File(pathToFirmware+File.separator+ncaFileName);
File nca = new File(PATH_TO_FIRMWARE +File.separator+ncaFileName);
NCAProvider provider = new NCAProvider(nca, keyChainHolder.getRawKeySet());
ncaProviders.add(provider);
}
@ -96,10 +89,10 @@ public class ExtractPackage2Test {
Path myFilePath1 = Paths.get(exportIntoFolder+File.separator+"ROOT"+File.separator+"nx"+File.separator+"package2");
Path myFilePath2 = Paths.get(exportIntoFolder+File.separator+"package2");
System.out.println();
System.out.println("Reference : " + referenceFilePath);
System.out.println("Own #1 : " + myFilePath1);
System.out.println("Own #2 : " + myFilePath2);
System.out.println("\n" +
"\nReference : " + referenceFilePath +
"\nOwn #1 : " + myFilePath1 +
"\nOwn #2 : " + myFilePath2);
romFsProvider.exportContent(exportIntoFolder, romFsProvider.getRootEntry());
long referenceCrc32 = calculateReferenceCRC32(referenceFilePath);

View file

@ -1,7 +1,6 @@
package libKonogonka.package2;
import libKonogonka.Converter;
import libKonogonka.KeyChainHolder;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
@ -27,19 +26,7 @@ import java.util.zip.CRC32;
* 2. INI1.bin extracted from NCA file via streams
* */
public class Ini1ExtractTest {
final String KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"prod.keys";
final String XCI_HEADER_KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"xci_header_key.txt";
final String pathToFirmware = "FilesForTests"+File.separator+"Firmware 14.1.0";
private static KeyChainHolder keyChainHolder;
final String referenceFat = "FilesForTests"+File.separator+"reference_for_system2"+File.separator+"FAT";
final String referenceExFat = "FilesForTests"+File.separator+"reference_for_system2"+File.separator+"ExFAT";
final String exportFat = System.getProperty("java.io.tmpdir")+File.separator+"Exported_FAT"+File.separator+getClass().getSimpleName();
final String exportExFat = System.getProperty("java.io.tmpdir")+File.separator+"Exported_ExFAT"+File.separator+getClass().getSimpleName();
public class Ini1ExtractTest extends LKonPackage2Test {
@DisplayName("INI1.bin extract test")
@Test
void testSystem2() throws Exception{
@ -61,22 +48,18 @@ public class Ini1ExtractTest {
Assertions.assertNotNull(system2FatNcaProvider);
Assertions.assertNotNull(system2ExFatNcaProvider);
System.out.println("FAT " + system2FatNcaProvider.getFile().getName());
System.out.println("ExFAT " + system2ExFatNcaProvider.getFile().getName());
System.out.println("FAT " + system2FatNcaProvider.getFile().getName() +
"\nExFAT " + system2ExFatNcaProvider.getFile().getName());
Assertions.assertTrue(system2FatNcaProvider.getFile().getName().endsWith("1212c.nca"));
Assertions.assertTrue(system2ExFatNcaProvider.getFile().getName().endsWith("cc081.nca"));
testExportedFiles(system2FatNcaProvider, exportFat, referenceFat);
testExportedFiles(system2ExFatNcaProvider, exportExFat, referenceExFat);
}
void makeKeys() throws Exception{
String keyValue = new String(Files.readAllBytes(Paths.get(XCI_HEADER_KEYS_FILE_LOCATION))).trim();
Assertions.assertNotEquals(0, keyValue.length());
keyChainHolder = new KeyChainHolder(KEYS_FILE_LOCATION, keyValue);
testExportedFiles(system2FatNcaProvider, exportFat, REFERENCE_FAT);
testExportedFiles(system2ExFatNcaProvider, exportExFat, REFERENCE_EXFAT);
}
String[] collectNcaFileNames(){
File firmware = new File(pathToFirmware);
File firmware = new File(PATH_TO_FIRMWARE);
Assertions.assertTrue(firmware.exists());
String[] ncaFileNames = firmware.list((File directory, String file) -> ( ! file.endsWith(".cnmt.nca") && file.endsWith(".nca")));
Assertions.assertNotNull(ncaFileNames);
@ -85,7 +68,7 @@ public class Ini1ExtractTest {
List<NCAProvider> makeNcaProviders(String[] ncaFileNames) throws Exception{
List<NCAProvider> ncaProviders = new ArrayList<>();
for (String ncaFileName : ncaFileNames){
File nca = new File(pathToFirmware+File.separator+ncaFileName);
File nca = new File(PATH_TO_FIRMWARE +File.separator+ncaFileName);
NCAProvider provider = new NCAProvider(nca, keyChainHolder.getRawKeySet());
ncaProviders.add(provider);
}
@ -112,9 +95,9 @@ public class Ini1ExtractTest {
Path referenceFilePath = Paths.get(referenceFilesFolder+File.separator+"package2"+File.separator+"INI1.bin");
Path myFilePath = Paths.get(exportIntoFolder+File.separator+"INI1.bin");
System.out.println();
System.out.println("Reference : " + referenceFilePath);
System.out.println("Own : " + myFilePath);
System.out.println("\n" +
"\nReference : " + referenceFilePath +
"\nOwn : " + myFilePath);
long referenceCrc32 = calculateReferenceCRC32(referenceFilePath);
romFsProvider.exportContent(exportIntoFolder, package2FileSystemEntry);

View file

@ -1,7 +1,6 @@
package libKonogonka.package2;
import libKonogonka.Converter;
import libKonogonka.KeyChainHolder;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
@ -24,23 +23,10 @@ import java.util.zip.CRC32;
* 2. Kernel.bin extracted from NCA file via streams
* */
public class KernelBinExtractTest {
final String KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"prod.keys";
final String XCI_HEADER_KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"xci_header_key.txt";
final String pathToFirmware = "FilesForTests"+File.separator+"Firmware 14.1.0";
private static KeyChainHolder keyChainHolder;
final String referenceFat = "FilesForTests"+File.separator+"reference_for_system2"+File.separator+"FAT";
final String referenceExFat = "FilesForTests"+File.separator+"reference_for_system2"+File.separator+"ExFAT";
final String exportFat = System.getProperty("java.io.tmpdir")+File.separator+"Exported_FAT"+File.separator+getClass().getSimpleName();
final String exportExFat = System.getProperty("java.io.tmpdir")+File.separator+"Exported_ExFAT"+File.separator+getClass().getSimpleName();
public class KernelBinExtractTest extends LKonPackage2Test {
@DisplayName("Kernel.bin extract test")
@Test
void testSystem2() throws Exception{
makeKeys();
String[] ncaFileNames = collectNcaFileNames();
List<NCAProvider> ncaProviders = makeNcaProviders(ncaFileNames);
@ -58,22 +44,18 @@ public class KernelBinExtractTest {
Assertions.assertNotNull(system2FatNcaProvider);
Assertions.assertNotNull(system2ExFatNcaProvider);
System.out.println("FAT " + system2FatNcaProvider.getFile().getName());
System.out.println("ExFAT " + system2ExFatNcaProvider.getFile().getName());
System.out.println("FAT " + system2FatNcaProvider.getFile().getName() +
"\nExFAT " + system2ExFatNcaProvider.getFile().getName());
Assertions.assertTrue(system2FatNcaProvider.getFile().getName().endsWith("1212c.nca"));
Assertions.assertTrue(system2ExFatNcaProvider.getFile().getName().endsWith("cc081.nca"));
testExportedFiles(system2FatNcaProvider, exportFat, referenceFat);
testExportedFiles(system2ExFatNcaProvider, exportExFat, referenceExFat);
}
void makeKeys() throws Exception{
String keyValue = new String(Files.readAllBytes(Paths.get(XCI_HEADER_KEYS_FILE_LOCATION))).trim();
Assertions.assertNotEquals(0, keyValue.length());
keyChainHolder = new KeyChainHolder(KEYS_FILE_LOCATION, keyValue);
testExportedFiles(system2FatNcaProvider, exportFat, REFERENCE_FAT);
testExportedFiles(system2ExFatNcaProvider, exportExFat, REFERENCE_EXFAT);
}
String[] collectNcaFileNames(){
File firmware = new File(pathToFirmware);
File firmware = new File(PATH_TO_FIRMWARE);
Assertions.assertTrue(firmware.exists());
String[] ncaFileNames = firmware.list((File directory, String file) -> ( ! file.endsWith(".cnmt.nca") && file.endsWith(".nca")));
Assertions.assertNotNull(ncaFileNames);
@ -82,7 +64,7 @@ public class KernelBinExtractTest {
List<NCAProvider> makeNcaProviders(String[] ncaFileNames) throws Exception{
List<NCAProvider> ncaProviders = new ArrayList<>();
for (String ncaFileName : ncaFileNames){
File nca = new File(pathToFirmware+File.separator+ncaFileName);
File nca = new File(PATH_TO_FIRMWARE +File.separator+ncaFileName);
NCAProvider provider = new NCAProvider(nca, keyChainHolder.getRawKeySet());
ncaProviders.add(provider);
}
@ -109,9 +91,9 @@ public class KernelBinExtractTest {
Path referenceFilePath = Paths.get(referenceFilesFolder+File.separator+"package2"+File.separator+"Kernel.bin");
Path myFilePath = Paths.get(exportIntoFolder+File.separator+"Kernel.bin");
System.out.println();
System.out.println("Reference : " + referenceFilePath);
System.out.println("Own : " + myFilePath);
System.out.println("\n" +
"\nReference : " + referenceFilePath +
"\nOwn : " + myFilePath);
long referenceCrc32 = calculateReferenceCRC32(referenceFilePath);
romFsProvider.exportContent(exportIntoFolder, package2FileSystemEntry);

View file

@ -1,7 +1,6 @@
package libKonogonka.package2;
import libKonogonka.Converter;
import libKonogonka.KeyChainHolder;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
@ -29,23 +28,10 @@ import java.util.zip.CRC32;
* 2. Decompressed KIP1 extracted from NCA file via streams
* */
public class Kip1ExtractDecompressedTest {
final String KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"prod.keys";
final String XCI_HEADER_KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"xci_header_key.txt";
final String pathToFirmware = "FilesForTests"+File.separator+"Firmware 14.1.0";
private static KeyChainHolder keyChainHolder;
final String referenceFat = "FilesForTests"+File.separator+"reference_for_system2"+File.separator+"FAT"+File.separator+"decompressed";
final String referenceExFat = "FilesForTests"+File.separator+"reference_for_system2"+File.separator+"ExFAT"+File.separator+"decompressed";
final String exportFat = System.getProperty("java.io.tmpdir")+File.separator+"Exported_FAT"+File.separator+getClass().getSimpleName();
final String exportExFat = System.getProperty("java.io.tmpdir")+File.separator+"Exported_ExFAT"+File.separator+getClass().getSimpleName();
public class Kip1ExtractDecompressedTest extends LKonPackage2Test {
@DisplayName("KIP1 extract test (case 'FS')")
@Test
void testSystem2() throws Exception{
makeKeys();
String[] ncaFileNames = collectNcaFileNames();
List<NCAProvider> ncaProviders = makeNcaProviders(ncaFileNames);
@ -63,22 +49,18 @@ public class Kip1ExtractDecompressedTest {
Assertions.assertNotNull(system2FatNcaProvider);
Assertions.assertNotNull(system2ExFatNcaProvider);
System.out.println("FAT " + system2FatNcaProvider.getFile().getName());
System.out.println("ExFAT " + system2ExFatNcaProvider.getFile().getName());
System.out.println("FAT " + system2FatNcaProvider.getFile().getName() +
"\nExFAT " + system2ExFatNcaProvider.getFile().getName());
Assertions.assertTrue(system2FatNcaProvider.getFile().getName().endsWith("1212c.nca"));
Assertions.assertTrue(system2ExFatNcaProvider.getFile().getName().endsWith("cc081.nca"));
testExportedFiles(system2FatNcaProvider, exportFat, referenceFat);
testExportedFiles(system2ExFatNcaProvider, exportExFat, referenceExFat);
}
void makeKeys() throws Exception{
String keyValue = new String(Files.readAllBytes(Paths.get(XCI_HEADER_KEYS_FILE_LOCATION))).trim();
Assertions.assertNotEquals(0, keyValue.length());
keyChainHolder = new KeyChainHolder(KEYS_FILE_LOCATION, keyValue);
testExportedFiles(system2FatNcaProvider, exportFat, REFERENCE_FAT);
testExportedFiles(system2ExFatNcaProvider, exportExFat, REFERENCE_EXFAT);
}
String[] collectNcaFileNames(){
File firmware = new File(pathToFirmware);
File firmware = new File(PATH_TO_FIRMWARE);
Assertions.assertTrue(firmware.exists());
String[] ncaFileNames = firmware.list((File directory, String file) -> ( ! file.endsWith(".cnmt.nca") && file.endsWith(".nca")));
Assertions.assertNotNull(ncaFileNames);
@ -87,7 +69,7 @@ public class Kip1ExtractDecompressedTest {
List<NCAProvider> makeNcaProviders(String[] ncaFileNames) throws Exception{
List<NCAProvider> ncaProviders = new ArrayList<>();
for (String ncaFileName : ncaFileNames){
File nca = new File(pathToFirmware+File.separator+ncaFileName);
File nca = new File(PATH_TO_FIRMWARE +File.separator+ncaFileName);
NCAProvider provider = new NCAProvider(nca, keyChainHolder.getRawKeySet());
ncaProviders.add(provider);
}

View file

@ -1,7 +1,6 @@
package libKonogonka.package2;
import libKonogonka.Converter;
import libKonogonka.KeyChainHolder;
import libKonogonka.fs.NCA.NCAProvider;
import libKonogonka.fs.RomFs.FileSystemEntry;
import libKonogonka.fs.RomFs.RomFsProvider;
@ -28,23 +27,10 @@ import java.util.zip.CRC32;
* 2. KIP1 extracted from NCA file via streams
* */
public class Kip1ExtractTest {
final String KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"prod.keys";
final String XCI_HEADER_KEYS_FILE_LOCATION = "FilesForTests"+File.separator+"xci_header_key.txt";
final String pathToFirmware = "FilesForTests"+File.separator+"Firmware 14.1.0";
private static KeyChainHolder keyChainHolder;
final String referenceFat = "FilesForTests"+File.separator+"reference_for_system2"+File.separator+"FAT";
final String referenceExFat = "FilesForTests"+File.separator+"reference_for_system2"+File.separator+"ExFAT";
final String exportFat = System.getProperty("java.io.tmpdir")+File.separator+"Exported_FAT"+File.separator+getClass().getSimpleName();
final String exportExFat = System.getProperty("java.io.tmpdir")+File.separator+"Exported_ExFAT"+File.separator+getClass().getSimpleName();
public class Kip1ExtractTest extends LKonPackage2Test {
@DisplayName("KIP1 extract test (case 'FS')")
@Test
void testSystem2() throws Exception{
makeKeys();
String[] ncaFileNames = collectNcaFileNames();
List<NCAProvider> ncaProviders = makeNcaProviders(ncaFileNames);
@ -62,22 +48,18 @@ public class Kip1ExtractTest {
Assertions.assertNotNull(system2FatNcaProvider);
Assertions.assertNotNull(system2ExFatNcaProvider);
System.out.println("FAT " + system2FatNcaProvider.getFile().getName());
System.out.println("ExFAT " + system2ExFatNcaProvider.getFile().getName());
System.out.println("FAT " + system2FatNcaProvider.getFile().getName() +
"\nExFAT " + system2ExFatNcaProvider.getFile().getName());
Assertions.assertTrue(system2FatNcaProvider.getFile().getName().endsWith("1212c.nca"));
Assertions.assertTrue(system2ExFatNcaProvider.getFile().getName().endsWith("cc081.nca"));
testExportedFiles(system2FatNcaProvider, exportFat, referenceFat);
testExportedFiles(system2ExFatNcaProvider, exportExFat, referenceExFat);
}
void makeKeys() throws Exception{
String keyValue = new String(Files.readAllBytes(Paths.get(XCI_HEADER_KEYS_FILE_LOCATION))).trim();
Assertions.assertNotEquals(0, keyValue.length());
keyChainHolder = new KeyChainHolder(KEYS_FILE_LOCATION, keyValue);
testExportedFiles(system2FatNcaProvider, exportFat, REFERENCE_FAT);
testExportedFiles(system2ExFatNcaProvider, exportExFat, REFERENCE_EXFAT);
}
String[] collectNcaFileNames(){
File firmware = new File(pathToFirmware);
File firmware = new File(PATH_TO_FIRMWARE);
Assertions.assertTrue(firmware.exists());
String[] ncaFileNames = firmware.list((File directory, String file) -> ( ! file.endsWith(".cnmt.nca") && file.endsWith(".nca")));
Assertions.assertNotNull(ncaFileNames);
@ -86,7 +68,7 @@ public class Kip1ExtractTest {
List<NCAProvider> makeNcaProviders(String[] ncaFileNames) throws Exception{
List<NCAProvider> ncaProviders = new ArrayList<>();
for (String ncaFileName : ncaFileNames){
File nca = new File(pathToFirmware+File.separator+ncaFileName);
File nca = new File(PATH_TO_FIRMWARE +File.separator+ncaFileName);
NCAProvider provider = new NCAProvider(nca, keyChainHolder.getRawKeySet());
ncaProviders.add(provider);
}
@ -113,9 +95,9 @@ public class Kip1ExtractTest {
Path referenceFilePath = Paths.get(referenceFilesFolder+File.separator+"ini1_extracted"+File.separator+"FS.kip1");
Path myFilePath = Paths.get(exportIntoFolder+File.separator+"FS.kip1");
System.out.println();
System.out.println("Reference : " + referenceFilePath);
System.out.println("Own : " + myFilePath);
System.out.println(
"\nReference : " + referenceFilePath +
"\nOwn : " + myFilePath);
long referenceCrc32 = calculateReferenceCRC32(referenceFilePath);
romFsProvider.exportContent(exportIntoFolder, package2FileSystemEntry);

View file

@ -0,0 +1,13 @@
package libKonogonka.package2;
import libKonogonka.LKonTest;
import java.io.File;
public class LKonPackage2Test extends LKonTest {
protected static final String REFERENCE_FAT = "FilesForTests"+ File.separator+"reference_for_system2"+File.separator+"FAT";
protected static final String REFERENCE_EXFAT = "FilesForTests"+File.separator+"reference_for_system2"+File.separator+"ExFAT";
protected String exportFat = TEMP_DIR+File.separator+"Exported_FAT"+File.separator+getClass().getSimpleName();
protected String exportExFat = TEMP_DIR+File.separator+"Exported_ExFAT"+File.separator+getClass().getSimpleName();
}