Pledge and unveil redbean's unit tests

This commit is contained in:
Justine Tunney 2022-07-23 05:22:19 -07:00
parent 513a659dd2
commit 31e4b0867b
21 changed files with 44 additions and 6 deletions

View file

@ -13,6 +13,8 @@
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
unix.pledge("stdio")
assert(assert(argon2.hash_encoded("password", "somesalt", {
variant = argon2.variants.argon2_i,
m_cost = 65536,

View file

@ -13,6 +13,8 @@
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
unix.pledge("stdio")
assert(EncodeJson(nil) == "null")
assert(EncodeJson(true) == "true")
assert(EncodeJson(false) == "false")

View file

@ -13,6 +13,8 @@
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
unix.pledge("stdio")
assert(EncodeLua(nil) == "nil")
assert(EncodeLua(true) == "true")
assert(EncodeLua(false) == "false")

View file

@ -1,3 +1,5 @@
unix.pledge("stdio")
-- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: fail11.json
assert(not DecodeJson([[

View file

@ -1,3 +1,5 @@
unix.pledge("stdio")
-- https://www.json.org/JSON_checker/test.zip
-- JSON parsing sample test case: pass1.json
assert(DecodeJson([[

View file

@ -26,6 +26,8 @@
-- SOFTWARE.
--
unix.pledge("stdio")
-- these test cases are prefixed with n_
-- ljson should reject all of them as invalid

View file

@ -26,6 +26,8 @@
-- SOFTWARE.
--
unix.pledge("stdio")
-- these test cases are prefixed with n_
-- ljson should reject all of them as invalid

View file

@ -26,6 +26,8 @@
-- SOFTWARE.
--
unix.pledge("stdio")
-- these test cases are prefixed with n_
-- ljson should reject all of them as invalid

View file

@ -26,6 +26,8 @@
-- SOFTWARE.
--
unix.pledge("stdio")
-- these test cases are prefixed with n_
-- ljson should reject all of them as invalid

View file

@ -26,6 +26,8 @@
-- SOFTWARE.
--
unix.pledge("stdio")
-- these test cases are prefixed with i_
-- ljson is free to accept or reject,
-- but we run them anyway to check for segfaults

View file

@ -26,6 +26,8 @@
-- SOFTWARE.
--
unix.pledge("stdio")
-- these test cases are prefixed with y_
-- ljson should accept all of them as valid

View file

@ -13,6 +13,8 @@
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
unix.pledge("stdio")
x = Rdtsc()
y = Rdtsc()
assert(y > x)

View file

@ -13,6 +13,8 @@
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
unix.pledge("stdio")
assert(EncodeLua(assert(DecodeJson[[ 0 ]])) == '0' )
assert(EncodeLua(assert(DecodeJson[[ [1] ]])) == '{1}')
assert(EncodeLua(assert(DecodeJson[[ 2.3 ]])) == '2.3')

View file

@ -13,6 +13,8 @@
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
unix.pledge("stdio")
assert(string.match("127.123.231.1", "%d+.%d+.%d+.%d+"))
assert(re.search([[^\d{1,3}(\.\d{1,3}){3}$]], "127.123.231.1"))

View file

@ -13,6 +13,8 @@
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
unix.pledge("stdio")
-- test redbean lua language extensions
assert(0b100 == 4)
assert(0200 == 128)

View file

@ -151,6 +151,9 @@ end
function main()
assert(unix.makedirs(tmpdir))
unix.unveil(tmpdir, "rwc")
unix.unveil(nil, nil)
unix.pledge("stdio rpath wpath cpath proc")
ok, err = pcall(UnixTest)
if ok then
assert(unix.rmrf(tmpdir))

View file

@ -13,6 +13,8 @@
-- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
unix.pledge("stdio")
assert("/usr/lib" == path.dirname("/usr/lib/foo.bar"))
assert("/usr" == path.dirname("/usr/lib"))
assert("usr" == path.dirname("usr/lib"))

View file

@ -38,6 +38,9 @@ end
local function main()
assert(unix.makedirs(tmpdir))
unix.unveil(tmpdir, "rwc")
unix.unveil(nil, nil)
unix.pledge("stdio rpath wpath cpath")
ok, err = pcall(SlurpTest)
if ok then
assert(unix.rmrf(tmpdir))