]> www.vanbest.org Git - sasc-ng.git/commitdiff
update testing code
authorleslie <unknown>
Thu, 27 Dec 2007 21:19:24 +0000 (22:19 +0100)
committerleslie <unknown>
Thu, 27 Dec 2007 21:19:24 +0000 (22:19 +0100)
testing/Makefile
testing/testN2Emu.c
testing/testN2RunEmu.c [new file with mode: 0644]

index fc03ea21cb6ce89e227884b9f18c7680217053a6..aaed3ad7a0cc443f7b2ad1bca85510d08a7a64e0 100644 (file)
@@ -40,7 +40,7 @@ $(VDRDIR)/%.o: $(VDRDIR)/%.c
 
 ### Targets:
 
-all: testECM testEMM testN1Emu testN2Emu
+all: testECM testEMM testN1Emu testN2Emu testN2RunEmu
 
 testECM.o: testECM.c compat.h
 testECM: testECM.o $(SHAREDOBJS) $(NOBJS)
@@ -54,14 +54,18 @@ testN1Emu.o: testN1Emu.c ../systems/nagra/nagra.c ../systems/nagra/nagra1.c ../s
 testN1Emu: testN1Emu.o $(SHAREDOBJS) $(NOBJS)
        $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@
 
-testN2Emu.o: testN2Emu.c ../systems/nagra/nagra2*.c ../systems/nagra/cpu.c
+testN2Emu.o: testN2Emu.c
 testN2Emu: testN2Emu.o $(SHAREDOBJS) $(NOBJS)
-       $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@
+       $(CXX) $(CXXFLAGS) $^ $(LIBS) -L../systems/nagra -lsc-nagra -o $@
+
+testN2RunEmu.o: testN2RunEmu.c
+testN2RunEmu: testN2RunEmu.o $(SHAREDOBJS) $(NOBJS)
+       $(CXX) $(CXXFLAGS) $^ $(LIBS) -L../systems/nagra -lsc-nagra -o $@
 
 filterhelper: filterhelper.o
        $(CXX) $(CXXFLAGS) $^ -o $@
 clean:
        @-rm -f *.o core* *~
-       @-rm -f testECM testEMM testN1Emu testN2Emu
+       @-rm -f testECM testEMM testN1Emu testN2Emu testN2RunEmu
        @-rm -f filterhelper
        @-rm -f dump.txt
index 3d36e62483b1c5de41c23b204fd8cf2ca721ffd6..f5ea4d43f915d6ae83603a422870cc50e85a5c34 100644 (file)
@@ -2,13 +2,10 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#define TESTER
 #include "crypto.h"
 #include "data.h"
 #include "system-common.h"
-#include "systems/nagra/cpu.c"
-#include "systems/nagra/nagra2.c"
-#include "systems/nagra/nagra.c"
+#include "systems/nagra/nagra2.h"
 
 #include "compat.h"
 
diff --git a/testing/testN2RunEmu.c b/testing/testN2RunEmu.c
new file mode 100644 (file)
index 0000000..8fbc70d
--- /dev/null
@@ -0,0 +1,49 @@
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "crypto.h"
+#include "data.h"
+#include "system-common.h"
+#include "systems/nagra/nagra2.h"
+
+#include "compat.h"
+
+int main(int argc, char *argv[])
+{
+  if(argc<4) {
+    printf("usage: %s <plugin-dir> <id> <cmd>\n",argv[0]);
+    return 1;
+    }
+
+  InitAll(argv[1]);
+  LogAll();
+  cLogging::SetModuleOption(LCLASS(L_SYS,L_SYS_DISASM),false);
+  unsigned char data[1024];
+  unsigned int len = 0;
+  char *p = argv[3];
+  char last = -1;
+  while(p < argv[3]+strlen(argv[3]) && len < sizeof(data)) {
+    if(*p == ' ' || *p == '\t') {
+      if(last>=0) { printf("failed to read data\n"); return 1; }
+      p++;
+      continue;
+      }
+    unsigned char b;
+    if(*p >= '0' && *p <= '9')      b = *p - '0';
+    else if(*p >= 'a' && *p <= 'f') b = *p - 'a' + 10;
+    else if(*p >= 'A' && *p <= 'F') b = *p - 'A' + 10;
+    else { printf("failed to read data\n"); return 1; }
+    if(last<0) last = b;
+    else {
+      data[len++] = (last << 4) | b;
+      last = -1;
+      }
+    p++;
+    }
+  int id=strtol(argv[2],0,0);
+  cN2Prov *emmP=cN2Providers::GetProv(id,N2FLAG_NONE);
+  HEXDUMP(0, data, len, "Input");
+  if(emmP->RunEmu(data, len, 0x90, 0x90, 0x00, 0x00, 0x300)>=0)
+    HEXDUMP(0, data, 0x300, "Output");
+}