foxygit / fake-08-xbox360 Log in
commit 8204ecbe482eddfc18816e752e0f6e4edd71821d
Author:     jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Thu Sep 10 11:44:28 2020 -0600
Commit:     jtothebell <j.to.the.bell@gmail.com>
CommitDate: Tue Sep 15 17:09:08 2020 -0600

    WIP getting tests running using lua
---
 .gitignore                   |  5 +++++
 libs/lua-5.3.2/Makefile      |  4 ++--
 libs/lua-5.3.2/src/Makefile  | 14 ++++++++------
 libs/lua-5.3.2/src/luaconf.h |  4 +++-
 test/Makefile                | 36 ++++++++++++++++++++++++++++++++++++
 test/cartpatchertests.cpp    | 11 +++++++++++
 test/graphicstests.cpp       |  1 +
 7 files changed, 66 insertions(+), 9 deletions(-)

diff --git a/.gitignore b/.gitignore
index c8924f2..d51e32e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,8 @@ build/

 test/testrunner.a
 test/*.o
+test/lib/
+test/include/
+
+libs/lua-5.3.2/src/*.o
+libs/lua-5.3.2/src/liblua.a
diff --git a/libs/lua-5.3.2/Makefile b/libs/lua-5.3.2/Makefile
index e87e958..c8fb3b0 100644
--- a/libs/lua-5.3.2/Makefile
+++ b/libs/lua-5.3.2/Makefile
@@ -39,10 +39,10 @@ RM= rm -f
 PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris

 # What to install.
-TO_BIN= lua luac
+TO_BIN=
 TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
 TO_LIB= liblua.a
-TO_MAN= lua.1 luac.1
+TO_MAN=

 # Lua version and release.
 V= 5.3
diff --git a/libs/lua-5.3.2/src/Makefile b/libs/lua-5.3.2/src/Makefile
index d71c75c..bb1fe28 100644
--- a/libs/lua-5.3.2/src/Makefile
+++ b/libs/lua-5.3.2/src/Makefile
@@ -36,11 +36,11 @@ LIB_O=	lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \
 	lmathlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o loadlib.o linit.o
 BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS)

-LUA_T=	lua
-LUA_O=	lua.o
+#LUA_T=	lua
+#LUA_O=	lua.o

-LUAC_T=	luac
-LUAC_O=	luac.o
+#LUAC_T=	luac
+#LUAC_O=	luac.o

 ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
 ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
@@ -181,8 +181,10 @@ ltable.o: ltable.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
 ltablib.o: ltablib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
 ltm.o: ltm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \
  llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h ltable.h lvm.h
-lua.o: lua.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
-luac.o: luac.c lprefix.h lua.h luaconf.h lauxlib.h lobject.h llimits.h \
+#not compiling lua interpreter/compiler (we only want the library)
+#possibly put this behind a flag to compile when on a desktop platform
+#lua.o: lua.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h
+#luac.o: luac.c lprefix.h lua.h luaconf.h lauxlib.h lobject.h llimits.h \
  lstate.h ltm.h lzio.h lmem.h lundump.h ldebug.h lopcodes.h
 lundump.o: lundump.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \
  lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h \
diff --git a/libs/lua-5.3.2/src/luaconf.h b/libs/lua-5.3.2/src/luaconf.h
index ba148bc..64c8be2 100644
--- a/libs/lua-5.3.2/src/luaconf.h
+++ b/libs/lua-5.3.2/src/luaconf.h
@@ -33,7 +33,7 @@
 ** ensure that all software connected to Lua will be compiled with the
 ** same configuration.
 */
-#define LUA_32BITS
+ #define LUA_32BITS


 /*
@@ -288,7 +288,9 @@
 ** You can define it to get all options, or change specific options
 ** to fit your specific needs.
 */
+#ifndef LUA_COMPAT_5_2
 #define LUA_COMPAT_5_2
+#endif
 #if defined(LUA_COMPAT_5_2)	/* { */

 /*
diff --git a/test/Makefile b/test/Makefile
index ad2f230..654fbe3 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -6,6 +6,16 @@ CFLAGS := -Wall -g -c -O2 \
 all: runtests


+#testrunner.a: testroot.o fontdatatests.o graphicstests.o audiotests.o cartpatchertests.o
+	#g++ -I$(CURDIR)/include -L$(CURDIR)/lib \
+	testroot.o \
+	fontdata.o fontdatatests.o \
+	graphics.o graphicstests.o stringToDataHelpers.o \
+	Audio.o synth.o audiotests.o \
+	cartPatcher.o cartpatchertests.o \
+	-llua -ldl \
+	-o testrunner.a
+
 testrunner.a: testroot.o fontdatatests.o graphicstests.o audiotests.o
 	g++ testroot.o \
 	fontdata.o fontdatatests.o \
@@ -30,6 +40,25 @@ audiotests.o: audiotests.cpp ../source/Audio.cpp ../source/Audio.h \
 	../source/PicoRam.h ../source/hostVmShared.h
 	g++ $(CFLAGS) audiotests.cpp ../source/Audio.cpp ../source/synth.cpp

+cartpatchertests.o: liblua.a cartpatchertests.cpp ../source/cartPatcher.cpp ../source/cartPatcher.h
+	g++ $(CFLAGS) -I$(CURDIR)/include -L$(CURDIR)/lib \
+	cartpatchertests.cpp ../source/cartPatcher.cpp \
+	-llua
+
+
+liblua.a:
+	@echo 'starting lua build\n' &&\
+	cd ../libs/lua-5.3.2 && make linux && \
+	cd ../../test && \
+	mkdir -p lib && \
+	mkdir -p include && \
+	cp ../libs/lua-5.3.2/src/liblua.a lib/liblua.a && \
+	cp ../libs/lua-5.3.2/src/lua.h include/lua.h && \
+	cp ../libs/lua-5.3.2/src/luaconf.h include/luaconf.h && \
+	cp ../libs/lua-5.3.2/src/lualib.h include/lualib.h && \
+	cp ../libs/lua-5.3.2/src/lauxlib.h include/lauxlib.h
+#make lua (cd ../libs/lua-5.3.2/src make linux, cp liblua.a, lua.h luaconf.h lualib.h lauxlib.h
+

 runtests: testrunner.a
 	./testrunner.a
@@ -37,4 +66,11 @@ runtests: testrunner.a
 clean:
 	-rm -f testrunner.a *.o

+echo:
+	@echo "CURDIR= $(CURDIR)"
+	@echo "CC= $(CC)"
+	@echo "CFLAGS= $(CFLAGS)"
+	@echo "LDFLAGS= $(SYSLDFLAGS)"
+	@echo "LIBS= $(LIBS)"
+
 .PHONY: all buildtests runtests clean
\ No newline at end of file
diff --git a/test/cartpatchertests.cpp b/test/cartpatchertests.cpp
new file mode 100644
index 0000000..c427957
--- /dev/null
+++ b/test/cartpatchertests.cpp
@@ -0,0 +1,11 @@
+#include <string>
+
+#include "doctest.h"
+#include "../source/cartPatcher.h"
+
+TEST_CASE("dummy testcase") {
+    std::string patched = getPatchedLua("");
+
+    //CHECK_EQ(patched.length(), 0);
+    CHECK_EQ(0, 0);
+}
\ No newline at end of file
diff --git a/test/graphicstests.cpp b/test/graphicstests.cpp
index 860aaa8..070876c 100644
--- a/test/graphicstests.cpp
+++ b/test/graphicstests.cpp
@@ -46,6 +46,7 @@ TEST_CASE("graphics class behaves as expected") {
     PicoRam picoRam;
     picoRam = {0};
     Graphics* graphics = new Graphics(fontdata, &picoRam);
+    graphics->cls();

     SUBCASE("Palette set up in constructor") {
         Color* palette = graphics->GetPaletteColors();