Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #7

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft

Add tests #7

wants to merge 24 commits into from

Conversation

Dragorn421
Copy link
Contributor

@Dragorn421 Dragorn421 commented Dec 19, 2022

Start adding tests

The current "test" stuff:

$ make -C test
make: Entering directory '/home/dragorn421/Documents/pygfxd/test'
./test.py
.........
----------------------------------------------------------------------
Ran 9 tests in 0.011s

OK
make: Leaving directory '/home/dragorn421/Documents/pygfxd/test'

Copy link
Owner

@Thar0 Thar0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rough thoughts on the current stuff

I like the idea of hosting simple tests from our own C files. Depending on how many tests there ends up being it would be nice to split each test into it's own python file, but this is fine for now. test.py in root can probably also go.

Three small nits

@@ -0,0 +1 @@
#include "../libgfxd/gbi.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could an include path for libgfxd be specified in the makefile rather than this dummy file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea with this wrapper .h would also be to let someone try another gbi.h, since libgfxd's is glank's i.e. not sgi's / decomp's

But yeah this can be changed idk

test/Makefile Outdated Show resolved Hide resolved
test/test.py Show resolved Hide resolved
subrepo:
  subdir:   "libgfxd"
  merged:   "7dd7fa1"
upstream:
  origin:   "https://github.com/glankk/libgfxd"
  branch:   "master"
  commit:   "7dd7fa1"
git-subrepo:
  version:  "0.4.5"
  origin:   "git@github.com:ingydotnet/git-subrepo.git"
  commit:   "dbb99be"
libgfxd 7dd7fa16227f6d4c336abfda353d01f833334413

Update/add `gfxd_light_callback`, `gfxd_lightsn_callback`
Add binding for `gfxd_foreach_pkt`
Update description for `gfxd_macro_fn`
Comment on lines +274 to +275
gfxd_target(gfxd_f3dex2)
gfxd_endian(GfxdEndian.big, 4)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about putting this everywhere 🤷
Probably deal with it if/when someone uses something other than the Superior ™️ Ucode f3dzex

test/test.py Outdated
Comment on lines 245 to 252
try:
gfxd_vtx_callback(callback)

gfxd_execute()
finally:
def callback(vtx, num):
return 0
gfxd_vtx_callback(callback)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this (try: ... finally: clear callback) is kind of bad I think, tests need to clear the state or it will mess with other states since libgfxd "keeps running"/is the same instance

Not sure what to do about it. "As long as it works" though is imo fine for tests

I only spotted this issue from adding this vtx callback test case, I should probably go over other callbacks and do the same


Also gfxd_vtx_callback(None) should eventually be made to work as you'd expect (afaict there currently is no way to unset a callback)

Comment on lines +144 to +152
def callback(bufP, count):
newdata = remaining_data[0][:count]
from ctypes import c_char

buftype = c_char * len(newdata)
buf = buftype.from_address(bufP)
buf[: len(newdata)] = newdata
remaining_data[0] = remaining_data[0][len(newdata) :]
return len(newdata)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this could be improved on the pygfxd wrapper side

@Dragorn421 Dragorn421 mentioned this pull request Dec 23, 2022
4 tasks
@Dragorn421 Dragorn421 changed the title [wip] Update libgfxd, tests Add tests Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants