Add some tests for the amalgamated source/

Adds tests to Makefile and CI on Poisx platforms.
This commit is contained in:
Calvin Rose 2019-05-23 10:34:01 -04:00
parent b5e6c0b8fc
commit a303704a7d
6 changed files with 53 additions and 4 deletions

View File

@ -9,3 +9,4 @@ tasks:
gmake test CC=gcc
sudo gmake install CC=gcc
gmake test-install CC=gcc
gmake test-amalg CC=gcc

View File

@ -8,3 +8,4 @@ tasks:
gmake test
doas gmake install
gmake test-install
gmake test-amalg

View File

@ -4,6 +4,7 @@ script:
- make test
- sudo make install
- make test-install
- make test-amalg
- make build/janet-${TRAVIS_TAG}-${TRAVIS_OS_NAME}.tar.gz
compiler:
- clang

View File

@ -304,6 +304,16 @@ install: $(JANET_TARGET) build/version.txt
test-install:
cd test/install && rm -rf build && janet build && janet build
build/embed_janet.o: build/janet.c $(JANET_HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
build/embed_main.o: test/amalg/main.c $(JANET_HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
build/embed_test: build/embed_janet.o build/embed_main.o
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(CLIBS)
test-amalg: build/embed_test
./build/embed_test
uninstall:
-rm $(BINDIR)/../$(JANET_TARGET)
-rm -rf $(INCLUDEDIR)

View File

@ -239,11 +239,11 @@ void janetc_copy(
return;
}
/* Process: src -> near -> dest */
int32_t near = janetc_allocnear(c, JANETC_REGTEMP_3);
janetc_movenear(c, near, src);
janetc_moveback(c, dest, near);
int32_t nearreg = janetc_allocnear(c, JANETC_REGTEMP_3);
janetc_movenear(c, nearreg, src);
janetc_moveback(c, dest, nearreg);
/* Cleanup */
janetc_regalloc_freetemp(&c->scope->ra, near, JANETC_REGTEMP_3);
janetc_regalloc_freetemp(&c->scope->ra, nearreg, JANETC_REGTEMP_3);
}
/* Instruction templated emitters */

36
test/amalg/main.c Normal file
View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2019 Calvin Rose
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
/* A simple client for checking if the amalgamated Janet source compiles
* correctly. */
#include <janet.h>
int main(int argc, const char *argv[]) {
(void) argc;
(void) argv;
janet_init();
JanetTable *env = janet_core_env(NULL);
janet_dostring(env, "(print `hello, world!`)", "main", NULL);
janet_deinit();
return 0;
}