From 2fe2eca105c6c979df03d358c877460e2a12ee84 Mon Sep 17 00:00:00 2001 From: Melvar Chen Date: Fri, 20 Dec 2013 20:55:22 +0100 Subject: [PATCH] Add regression test for possibly-null foreign strings in the executor --- idris.cabal | 3 +++ test/README | 1 + test/reg029/expected | 4 ++++ test/reg029/reg029.idr | 10 ++++++++++ test/reg029/run | 5 +++++ 5 files changed, 23 insertions(+) create mode 100644 test/reg029/expected create mode 100644 test/reg029/reg029.idr create mode 100755 test/reg029/run diff --git a/idris.cabal b/idris.cabal index 9fec86301..41c57285c 100644 --- a/idris.cabal +++ b/idris.cabal @@ -177,6 +177,9 @@ Extra-source-files: test/reg024/run test/reg024/*.idr test/reg024/expected + test/reg029/run + test/reg029/*.idr + test/reg029/expected test/test001/run test/test001/*.idr test/test001/expected diff --git a/test/README b/test/README index f6a2c080c..42c8a82b1 100644 --- a/test/README +++ b/test/README @@ -37,4 +37,5 @@ Tests: regxxx: various regression tests reg020: working strlen +reg029: executor doesn’t crash receiving a NULL String from C diff --git a/test/reg029/expected b/test/reg029/expected new file mode 100644 index 000000000..521967605 --- /dev/null +++ b/test/reg029/expected @@ -0,0 +1,4 @@ +Nothing +Just "exists!" +Nothing +Just "exists!" diff --git a/test/reg029/reg029.idr b/test/reg029/reg029.idr new file mode 100644 index 000000000..93d1a2e4f --- /dev/null +++ b/test/reg029/reg029.idr @@ -0,0 +1,10 @@ +module Main + +import System + +%dynamic "libm" + +main : IO () +main = do + print !(getEnv "IDRIS_REG029_NONEXISTENT_VAR") + print !(getEnv "IDRIS_REG029_EXISTENT_VAR") diff --git a/test/reg029/run b/test/reg029/run new file mode 100755 index 000000000..8e55d1f6a --- /dev/null +++ b/test/reg029/run @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +idris $@ reg029.idr -o reg029 +env -u IDRIS_REG029_NONEXISTENT_VAR IDRIS_REG029_EXISTENT_VAR='exists!' ./reg029 +env -u IDRIS_REG029_NONEXISTENT_VAR IDRIS_REG029_EXISTENT_VAR='exists!' idris $@ reg029.idr --exec +rm -f reg029 *.ibc