]> gitweb.factorcode.org Git - factor.git/blob - extra/macho/macho-tests.factor
48626fcaf3630bd62ff429cb0a6de14ffc4250db
[factor.git] / extra / macho / macho-tests.factor
1 ! Copyright (C) 2010 Erik Charlebois.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: accessors alien http.download io.files.temp
4 io.streams.string kernel literals macho multiline sequences
5 system tools.test urls ;
6 IN: macho.tests
7
8 STRING: validation-output
9 0000000100000f1c __stub_helper    stub helpers
10 0000000100001040 __program_vars  _pvars
11 0000000100001068 __data          _NXArgc
12 0000000100001070 __data          _NXArgv
13 0000000100001080 __data          ___progname
14 0000000100000000                 __mh_execute_header
15 0000000100001078 __data          _environ
16 0000000100000ef8 __text          _main
17 0000000100000ebc __text          start
18 0000000000000000                 ___gxx_personality_v0
19 0000000000000000                 _exit
20 0000000000000000                 _printf
21 0000000000000000                 dyld_stub_binder
22
23 ;
24
25 : a.macho ( -- path )
26     URL" https://downloads.factorcode.org/misc/a.macho"
27     "a.macho" cache-file download-to ;
28
29 : a2.macho ( -- path )
30     URL" https://downloads.factorcode.org/misc/a2.macho"
31     "a2.macho" cache-file download-to ;
32
33 cpu ppc? [
34     { $ validation-output }
35     [ [ a.macho macho-nm ] with-string-writer ]
36     unit-test
37
38     { t } [
39         a2.macho [
40             >c-ptr fat-binary-members first data>> >c-ptr macho-header 64-bit?
41         ] with-mapped-macho
42     ] unit-test
43 ] unless
44
45 ! Throw an exception if the struct is not defined/handled
46 os macosx? [
47     { } [ vm-path dylib-exports drop ] unit-test
48 ] when