diff --git a/.gitignore b/.gitignore index c6c6a9a..6acbd46 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,15 @@ -SOURCES/lua-5.3.4-tests.tar.gz -SOURCES/lua-5.3.4.tar.gz -/lua-5.3.4-tests.tar.gz +lua-5.1.4.tar.gz +lua-5.1.4/ +.build* +*.src.rpm +/x86_64/ +/i386/ +/lua-5.2.2.tar.gz +/lua-5.2.3.tar.gz +/lua-5.3.0.tar.gz +/lua-5.3.2-tests.tar.gz +/lua-5.3.2.tar.gz +/lua-5.3.3.tar.gz +/lua-5.3.3-tests.tar.gz /lua-5.3.4.tar.gz +/lua-5.3.4-tests.tar.gz diff --git a/lua-5.2.2-configure-compat-module.patch b/lua-5.2.2-configure-compat-module.patch new file mode 100644 index 0000000..80bb047 --- /dev/null +++ b/lua-5.2.2-configure-compat-module.patch @@ -0,0 +1,34 @@ +diff -up lua-5.2.2/configure.ac.compat-module lua-5.2.2/configure.ac +--- lua-5.2.2/configure.ac.compat-module 2013-05-10 10:16:05.344137597 -0400 ++++ lua-5.2.2/configure.ac 2013-05-10 10:16:05.357137596 -0400 +@@ -11,6 +11,19 @@ AC_PROG_CC + AC_PROG_LIBTOOL + + AC_ARG_WITH( ++ [compat-module], ++ [AC_HELP_STRING([--with-compat-module], [Enable LUA_COMPAT_MODULE functions [default=no]])], ++ [use_compat_module=$withval], ++ [use_compat_module=no] ++) ++ ++COMPAT_DEFS="#undef LUA_COMPAT_ALL" ++if test "x$use_compat_module" == "xyes"; then ++ COMPAT_DEFS="#define LUA_COMPAT_ALL" ++fi ++AC_SUBST(COMPAT_DEFS) ++ ++AC_ARG_WITH( + [readline], + [AC_HELP_STRING([--with-readline], [Use readline for interpreter input [default=yes]])], + [use_readline=$withval], +diff -up lua-5.2.2/src/luaconf.h.template.in.compat-module lua-5.2.2/src/luaconf.h.template.in +--- lua-5.2.2/src/luaconf.h.template.in.compat-module 2013-05-10 10:25:42.586116963 -0400 ++++ lua-5.2.2/src/luaconf.h.template.in 2013-05-10 10:26:29.957115269 -0400 +@@ -15,6 +15,7 @@ + @LUA_DL_DEFS@ + @LUA_BUILD_AS_DLL_DEFS@ + @READLINE_DEFS@ ++@COMPAT_DEFS@ + + + /* diff --git a/lua-5.2.2-idsize.patch b/lua-5.2.2-idsize.patch new file mode 100644 index 0000000..7388a07 --- /dev/null +++ b/lua-5.2.2-idsize.patch @@ -0,0 +1,13 @@ +diff --git a/src/luaconf.h.template.in b/src/luaconf.h.template.in +index a427c53..6f1d567 100644 +--- a/src/luaconf.h.template.in ++++ b/src/luaconf.h.template.in +@@ -206,7 +206,7 @@ + @* of a function in debug information. + ** CHANGE it if you want a different size. + */ +-#define LUA_IDSIZE 60 ++#define LUA_IDSIZE 512 + + + /* diff --git a/lua-5.2.2-luac-shared-link-fix.patch b/lua-5.2.2-luac-shared-link-fix.patch new file mode 100644 index 0000000..6c9eb99 --- /dev/null +++ b/lua-5.2.2-luac-shared-link-fix.patch @@ -0,0 +1,54 @@ +diff -up lua-5.2.2/src/lopcodes.c.luac-shared lua-5.2.2/src/lopcodes.c +--- lua-5.2.2/src/lopcodes.c.luac-shared 2012-05-14 09:34:18.000000000 -0400 ++++ lua-5.2.2/src/lopcodes.c 2013-05-09 14:36:30.874581104 -0400 +@@ -14,7 +14,7 @@ + + /* ORDER OP */ + +-LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { ++LUA_API const char *const luaP_opnames[NUM_OPCODES+1] = { + "MOVE", + "LOADK", + "LOADKX", +@@ -61,7 +61,7 @@ LUAI_DDEF const char *const luaP_opnames + + #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) + +-LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { ++LUA_API const lu_byte luaP_opmodes[NUM_OPCODES] = { + /* T A B C mode opcode */ + opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ +diff -up lua-5.2.2/src/lopcodes.h.luac-shared lua-5.2.2/src/lopcodes.h +--- lua-5.2.2/src/lopcodes.h.luac-shared 2013-05-09 14:37:14.718581762 -0400 ++++ lua-5.2.2/src/lopcodes.h 2013-05-09 14:37:40.998582156 -0400 +@@ -269,7 +269,7 @@ enum OpArgMask { + OpArgK /* argument is a constant or register/constant */ + }; + +-LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES]; ++LUA_API const lu_byte luaP_opmodes[NUM_OPCODES]; + + #define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) + #define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) +@@ -278,7 +278,7 @@ LUAI_DDEC const lu_byte luaP_opmodes[NUM + #define testTMode(m) (luaP_opmodes[m] & (1 << 7)) + + +-LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ ++LUA_API const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ + + + /* number of list items to accumulate before a SETLIST instruction */ +diff -up lua-5.2.2/src/lundump.h.luac-shared lua-5.2.2/src/lundump.h +--- lua-5.2.2/src/lundump.h.luac-shared 2012-05-08 09:53:33.000000000 -0400 ++++ lua-5.2.2/src/lundump.h 2013-05-09 14:36:30.874581104 -0400 +@@ -17,7 +17,7 @@ LUAI_FUNC Closure* luaU_undump (lua_Stat + LUAI_FUNC void luaU_header (lu_byte* h); + + /* dump one chunk; from ldump.c */ +-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); ++LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); + + /* data to catch conversion errors */ + #define LUAC_TAIL "\x19\x93\r\n\x1a\n" diff --git a/lua-5.2.3-autotoolize.patch b/lua-5.2.3-autotoolize.patch new file mode 100644 index 0000000..02a59fe --- /dev/null +++ b/lua-5.2.3-autotoolize.patch @@ -0,0 +1,204 @@ +diff --git a/Makefile.am b/Makefile.am +new file mode 100644 +index 0000000..8d968c4 +--- /dev/null ++++ b/Makefile.am +@@ -0,0 +1,3 @@ ++SUBDIRS = src doc ++ ++EXTRA_DIST = README +diff --git a/configure.ac b/configure.ac +new file mode 100644 +index 0000000..3af6625 +--- /dev/null ++++ b/configure.ac +@@ -0,0 +1,69 @@ ++AC_PREREQ(2.59) ++AC_INIT([lua], [5.2.3], [https://bugzilla.redhat.com/], [lua-at], [http://www.lua.org]) ++AC_SUBST([MAJOR_VERSION], [5.2]) ++ ++AC_CONFIG_HEADERS([config.h]) ++AC_CONFIG_SRCDIR([src/lapi.c]) ++ ++AM_INIT_AUTOMAKE([1.9 foreign]) ++ ++AC_PROG_CC ++AC_PROG_LIBTOOL ++ ++AC_ARG_WITH( ++ [readline], ++ [AC_HELP_STRING([--with-readline], [Use readline for interpreter input [default=yes]])], ++ [use_readline=$withval], ++ [use_readline=yes] ++) ++ ++LUA_LIBS="-lm" ++ ++# Check for readline ++READLINE_DEFS="#undef LUA_USE_READLINE" ++if test "x$use_readline" == "xyes"; then ++ AC_CHECK_LIB([readline], [readline], [:], [use_readline=no], [-lncurses]) ++ AC_CHECK_HEADERS([readline/readline.h readline/history.h], [], [use_readline=no]) ++ if test "x$use_readline" == "xno"; then ++ AC_MSG_WARN([readline headers could not be found, disabling readline support]) ++ else ++ READLINE_DEFS="#define LUA_USE_READLINE" ++ READLINE_LIBS="-lreadline -lncurses" ++ fi ++fi ++AC_SUBST(READLINE_DEFS) ++AC_SUBST(READLINE_LIBS) ++ ++case "$host" in ++ *-mingw*) use_os=win32 ;; ++ *-darwin*) use_os=macosx ;; ++ *) use_os=posix ;; ++esac ++ ++POSIX_DEFS="#undef LUA_USE_POSIX" ++LUA_DL_DEFS="#undef LUA_USE_DLOPEN" ++LUA_BUILD_AS_DLL_DEFS="#undef LUA_BUILD_AS_DLL" ++ ++if test "x$use_os" == "xwin32"; then ++ LUA_BUILD_AS_DLL_DEFS="#define LUA_BUILD_AS_DLL" ++elif test "x$use_os" == "xmacosx"; then ++ POSIX_DEFS="#define LUA_USE_POSIX" ++ LUA_DL_DEFS="#define LUA_DL_DYLD" ++elif test "x$use_os" == "xposix"; then ++ POSIX_DEFS="#define LUA_USE_POSIX" ++ LUA_DL_DEFS="#define LUA_DL_DLOPEN" ++ LUA_LIBS="$LUA_LIBS -ldl" ++fi ++AC_SUBST(POSIX_DEFS) ++AC_SUBST(LUA_DL_DEFS) ++AC_SUBST(LUA_BUILD_AS_DLL_DEFS) ++ ++AC_SUBST(LUA_LIBS) ++ ++AC_CONFIG_FILES([Makefile ++ src/Makefile ++ src/lua.pc ++ src/luaconf.h.template ++ doc/Makefile ++]) ++AC_OUTPUT +diff --git a/doc/Makefile.am b/doc/Makefile.am +new file mode 100644 +index 0000000..3705696 +--- /dev/null ++++ b/doc/Makefile.am +@@ -0,0 +1,4 @@ ++man1_MANS = lua.1 luac.1 ++ ++EXTRA_DIST = \ ++ contents.html logo.gif lua.1 luac.1 lua.css manual.css manual.html osi-certified-72x60.png readme.html +diff --git a/src/.gitignore b/src/.gitignore +new file mode 100644 +index 0000000..0abd9dd +--- /dev/null ++++ b/src/.gitignore +@@ -0,0 +1,5 @@ ++lua ++lua.pc ++luac ++luaconf.h ++luaconf.h.template +diff --git a/src/Makefile.am b/src/Makefile.am +new file mode 100644 +index 0000000..6c7c79f +--- /dev/null ++++ b/src/Makefile.am +@@ -0,0 +1,46 @@ ++AM_CFLAGS = -Wall ++ ++include_HEADERS = lua.h lualib.h lauxlib.h lua.hpp ++ ++nodist_include_HEADERS = luaconf.h ++ ++lib_LTLIBRARIES = liblua.la ++liblua_la_LDFLAGS = -release @MAJOR_VERSION@ ++liblua_la_SOURCES = \ ++ lapi.c lauxlib.c lbaselib.c lbitlib.c lcode.c lcorolib.c lctype.c ldblib.c \ ++ ldebug.c ldo.c ldump.c lfunc.c lgc.c linit.c liolib.c llex.c lmathlib.c lmem.c \ ++ loadlib.c lobject.c lopcodes.c loslib.c lparser.c lstate.c lstring.c lstrlib.c \ ++ ltable.c ltablib.c ltm.c lundump.c lvm.c lzio.c \ ++ lapi.h lcode.h lctype.h ldebug.h ldo.h lfunc.h lgc.h llex.h llimits.h \ ++ lmem.h lobject.h lopcodes.h lparser.h lstate.h lstring.h ltable.h ltm.h \ ++ lundump.h lvm.h lzio.h ++ ++pkgconfigdir = $(libdir)/pkgconfig ++pkgconfig_DATA = lua.pc ++ ++bin_PROGRAMS = lua luac ++ ++lua_SOURCES = lua.c ++lua_LDADD = liblua.la @LUA_LIBS@ @READLINE_LIBS@ ++lua_DEPENDENCIES = liblua.la ++ ++luac_SOURCES = luac.c ++# Statically link liblua against luac since luac uses symbols not exported in liblua ++luac_LDADD = .libs/liblua.a @LUA_LIBS@ ++luac_DEPENDENCIES = liblua.la ++ ++EXTRA_DIST = luaconf.h.template ++BUILT_SOURCES = luaconf.h ++CLEANFILES = luaconf.h luaconf.h.template ++ ++readline_defs = @READLINE_DEFS@ ++ ++edit = sed \ ++ -e 's,%prefix%,$(prefix),g' \ ++ -e 's,%lua_datadir%,$(datadir),g' \ ++ -e 's,%lua_libdir%,$(libdir),g' ++ ++luaconf.h : luaconf.h.template ++ rm -f $@ $@.tmp ++ $(edit) $< >$@.tmp ++ mv $@.tmp $@ +diff --git a/src/lua.pc.in b/src/lua.pc.in +new file mode 100644 +index 0000000..25faa8d +--- /dev/null ++++ b/src/lua.pc.in +@@ -0,0 +1,13 @@ ++V= @MAJOR_VERSION@ ++R= @VERSION@ ++prefix= @prefix@ ++exec_prefix=${prefix} ++libdir= @libdir@ ++includedir=${prefix}/include ++ ++Name: Lua ++Description: An Extensible Extension Language ++Version: ${R} ++Requires: ++Libs: -llua @LUA_LIBS@ ++Cflags: -I${includedir} +diff --git a/src/luaconf.h b/src/luaconf.h.template.in +--- a/src/luaconf.h.template.in ++++ b/src/luaconf.h.template.in +@@ -11,6 +11,11 @@ + #include + #include + ++@POSIX_DEFS@ ++@LUA_DL_DEFS@ ++@LUA_BUILD_AS_DLL_DEFS@ ++@READLINE_DEFS@ ++ + + /* + ** ================================================================== +@@ -100,9 +105,9 @@ + #else /* }{ */ + + #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/" +-#define LUA_ROOT "/usr/local/" +-#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR +-#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR ++#define LUA_ROOT "@prefix@/" ++#define LUA_LDIR "@pkgdatadir@/lua/" LUA_VDIR ++#define LUA_CDIR "@libdir@/lua/" LUA_VDIR + #define LUA_PATH_DEFAULT \ + LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua" diff --git a/sources b/sources index 2ee265f..501c52d 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (lua-5.3.4-tests.tar.gz) = 79575d100a2efabc8243f55b55d912443e09ef7e8b0219cb93541d85c2ba802fb9538015e1228703f09ca57bdb28a640a8f1fa0735716ba1e4bca2179c712dfb SHA512 (lua-5.3.4.tar.gz) = 739e31f82e6a60fa99910c2005e991b3a1e21339af52847f653cb190b30842054d189ca116ffcfdf9b36e07888c9ce5642b1dd2988cc7eff9f8789f9a2e34997 +SHA512 (lua-5.3.4-tests.tar.gz) = 79575d100a2efabc8243f55b55d912443e09ef7e8b0219cb93541d85c2ba802fb9538015e1228703f09ca57bdb28a640a8f1fa0735716ba1e4bca2179c712dfb diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..5683070 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,3 @@ +# lua + +lua tests \ No newline at end of file diff --git a/tests/Smoke/Makefile b/tests/Smoke/Makefile new file mode 100644 index 0000000..cc6503b --- /dev/null +++ b/tests/Smoke/Makefile @@ -0,0 +1,63 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/lua/Sanity/Smoke +# Description: Basic smoke for lua component +# Author: Stepan Sigut +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/CoreOS/lua/Sanity/Smoke +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE *.lua + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Stepan Sigut " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Basic smoke for lua component" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 5m" >> $(METADATA) + @echo "RunFor: lua" >> $(METADATA) + @echo "Requires: lua" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Smoke/PURPOSE b/tests/Smoke/PURPOSE new file mode 100644 index 0000000..fc1a3f3 --- /dev/null +++ b/tests/Smoke/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/lua/Sanity/Smoke +Description: Basic smoke for lua component +Author: Stepan Sigut diff --git a/tests/Smoke/account.lua b/tests/Smoke/account.lua new file mode 100644 index 0000000..e783c01 --- /dev/null +++ b/tests/Smoke/account.lua @@ -0,0 +1,35 @@ +-- account.lua +-- from PiL 1, Chapter 16 + +Account = {balance = 0} + +function Account:new (o, name) + o = o or {name=name} + setmetatable(o, self) + self.__index = self + return o +end + +function Account:deposit (v) + self.balance = self.balance + v +end + +function Account:withdraw (v) + if v > self.balance then error("insufficient funds on account "..self.name) end + self.balance = self.balance - v +end + +function Account:show (title) + print(title or "", self.name, self.balance) +end + +a = Account:new(nil,"demo") +a:show("after creation") +a:deposit(1000.00) +a:show("after deposit") +a:withdraw(100.00) +a:show("after withdraw") + +-- this would raise an error +b = Account:new(nil,"DEMO") +b:withdraw(100.00) diff --git a/tests/Smoke/bisect.lua b/tests/Smoke/bisect.lua new file mode 100644 index 0000000..77ac36c --- /dev/null +++ b/tests/Smoke/bisect.lua @@ -0,0 +1,28 @@ +-- bisect.lua +-- bisection method for solving non-linear equations + +delta=1e-6 -- tolerance + +function bisect(f,a,b,fa,fb) + local c=(a+b)/2 + io.write(n," c=",c," a=",a," b=",b,"\n") + if c==a or c==b or math.abs(a-b) +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2016 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/bin/rhts-environment.sh || exit 1 +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES=${PACKAGES:-"lua"} +LUA=${LUA:-"lua"} + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlAssertBinaryOrigin $LUA + set -o pipefail + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp *.lua $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "$LUA hello.lua 2>&1 | tee dump.log" 0 + rlAssertGrep "Hello world, from Lua" "dump.log" + rlPhaseEnd + rlPhaseStartTest + rlRun "$LUA bisect.lua 2>&1 | tee dump.log" 0 + rlAssertGrep "after 20 steps, root is 1.3247179985046387 with error 9.5e-07, f=1.8e-07" "dump.log" + rlPhaseEnd + rlPhaseStartTest + rlRun "$LUA globals.lua &>/dev/null" 0 + rlPhaseEnd + rlPhaseStartTest + rlRun "$LUA account.lua 2>&1 | tee dump.log" 1 + rlAssertGrep "after creation" "dump.log" + rlAssertGrep "lua: account.lua:18: insufficient funds on account DEMO" "dump.log" + rlPhaseEnd + rlPhaseStartTest + rlRun "$LUA sieve.lua &>/dev/null" 0 + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/Smoke/sieve.lua b/tests/Smoke/sieve.lua new file mode 100644 index 0000000..4ce8456 --- /dev/null +++ b/tests/Smoke/sieve.lua @@ -0,0 +1,28 @@ +-- sieve.lua +-- the sieve of Eratosthenes programmed with coroutines +-- typical usage: lua -e N=500 sieve.lua | column + +-- generate all the numbers from 2 to n +function gen (n) + return coroutine.wrap(function () + for i=2,n do coroutine.yield(i) end + end) +end + +-- filter the numbers generated by `g', removing multiples of `p' +function filter (p, g) + return coroutine.wrap(function () + for n in g do + if n%p ~= 0 then coroutine.yield(n) end + end + end) +end + +N=N or 500 -- from command line +x = gen(N) -- generate primes up to N +while 1 do + local n = x() -- pick a number until done + if n == nil then break end + print(n) -- must be a prime number + x = filter(n, x) -- now remove its multiples +end diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..2613885 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,14 @@ +--- +# This first play always runs on the local staging system +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - classic + - container + - atomic + tests: + - Smoke + required_packages: + - lua # Required for smoke test + - which # Required for smoke test