From 05fe766c188bb2be27e91782d335bf781667398a Mon Sep 17 00:00:00 2001 From: leslie Date: Thu, 27 Dec 2007 22:19:24 +0100 Subject: [PATCH] update testing code --- testing/Makefile | 12 +++++++---- testing/testN2Emu.c | 5 +---- testing/testN2RunEmu.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 testing/testN2RunEmu.c diff --git a/testing/Makefile b/testing/Makefile index fc03ea2..aaed3ad 100644 --- a/testing/Makefile +++ b/testing/Makefile @@ -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 diff --git a/testing/testN2Emu.c b/testing/testN2Emu.c index 3d36e62..f5ea4d4 100644 --- a/testing/testN2Emu.c +++ b/testing/testN2Emu.c @@ -2,13 +2,10 @@ #include #include -#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 index 0000000..8fbc70d --- /dev/null +++ b/testing/testN2RunEmu.c @@ -0,0 +1,49 @@ + +#include +#include + +#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 \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"); +} -- 2.39.5