Skip to content

Commit

Permalink
autorun lua test
Browse files Browse the repository at this point in the history
  • Loading branch information
ihaveamac committed Dec 14, 2024
1 parent 9df4a05 commit 0d7b03c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "GodMode9"]
path = GodMode9
url = https://github.com/d0k3/GodMode9
url = https://github.com/ihaveamac/GodMode9
branch = real-lua-attempt
2 changes: 1 addition & 1 deletion GodMode9
Submodule GodMode9 updated 163 files
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ builds/finalize.romfs: builds
@3dstool -c -t romfs --romfs-dir romfs --file $@

builds/x_finalize_helper.firm: builds/finalize.romfs
@cp finalize_helper.gm9 GodMode9/data/autorun.gm9
@sed -i s/FINALIZE_SHA256SUM/$(shell sha256sum $< | awk '{print $$1}')/g GodMode9/data/autorun.gm9
@cp finalize_helper.lua GodMode9/data/autorun.lua
@sha256sum $< | awk '{print $$1}' > GodMode9/data/finalize-romfs-hash.txt
@$(MAKE) -C GodMode9 SCRIPT_RUNNER=1
@cp GodMode9/output/GodMode9.firm $@
@printf '\001' | dd conv=notrunc bs=1 seek=16 of=$@
Expand Down
24 changes: 24 additions & 0 deletions finalize_helper.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ui.echo("Testing!\n \nThis is a test.\n \nI will now try to verify finalize.romfs.")

local success, hash_expected = pcall(fs.read_file, CURRDIR.."/finalize-romfs-hash.txt", 0, 64)
if not success then
ui.echo("Failed to read hash txt?\n"..hash_expected)
sys.power_off()
end

print("Expected:", hash_expected)
local success, hash_got = pcall(fs.hash_file, "0:/finalize.romfs", 0, 0)
if not success then
ui.echo("Failed to hash finalize.romfs\n"..hash_got)
sys.power_off()
end

hash_got = util.bytes_to_hex(hash_got)

print("Got: ", hash_got)

if hash_got == hash_expected then
ui.echo("Success!")
else
ui.echo("Failure...")
end

0 comments on commit 0d7b03c

Please sign in to comment.