cp -p, run tests in %check

tags/lua-ldap-1.1.0-19
Dan Callaghan 10 years ago
parent 1cad9b9a7f
commit 680634475f
  1. 58
      0001-update-test.lua-for-5.2.patch
  2. 99
      0002-script-to-run-test.lua-against-a-dummy-slapd.patch
  3. 2
      destdir.patch
  4. 35
      fix-attempt-to-concatenate-a-nil-value.patch
  5. 39
      lua-ldap.spec

@ -0,0 +1,58 @@
From 85891948cd7b6e9eed2c0e4b199de2a8d19a0824 Mon Sep 17 00:00:00 2001
From: Dan Callaghan <dcallagh@redhat.com>
Date: Mon, 30 Jun 2014 11:18:04 +1000
Subject: [PATCH 1/2] update test.lua for 5.2
diff --git a/lualdap/tests/test.lua b/lualdap/tests/test.lua
index 2dce95b..76c8640 100755
--- a/lualdap/tests/test.lua
+++ b/lualdap/tests/test.lua
@@ -27,7 +27,7 @@ function print_attrs (dn, attrs)
if tv == "string" then
io.write (values)
elseif tv == "table" then
- local n = table.getn (values)
+ local n = #values
for i = 1, n-1 do
io.write (values[i]..",")
end
@@ -77,7 +77,7 @@ function test_object (obj, objmethods)
-- trying to set metatable.
assert2 (false, pcall (setmetatable, ENV, {}))
-- checking existence of object's methods.
- for i = 1, table.getn (objmethods) do
+ for i = 1, #objmethods do
local method = obj[objmethods[i]]
assert2 ("function", type(method))
assert2 (false, pcall (method), "no 'self' parameter accepted")
@@ -128,7 +128,7 @@ end
-- checks return value which should be a function AND also its return value.
---------------------------------------------------------------------
function check_future (ret, method, ...)
- local ok, f = pcall (method, unpack (arg))
+ local ok, f = pcall (method, ...)
assert (ok, f)
assert2 ("function", type(f))
assert2 (ret, f())
@@ -377,7 +377,7 @@ tests = {
-- Main
---------------------------------------------------------------------
-if table.getn(arg) < 1 then
+if #arg < 1 then
print (string.format ("Usage %s host[:port] base [who [password]]", arg[0]))
os.exit()
end
@@ -390,7 +390,7 @@ PASSWORD = arg[4]
require"lualdap"
assert (type(lualdap)=="table", "couldn't load LDAP library")
-for i = 1, table.getn (tests) do
+for i = 1, #tests do
local t = tests[i]
io.write (t[1].." ...")
t[2] ()
--
1.9.3

@ -0,0 +1,99 @@
From 847bbf5dbd8053ce21c90dd808ed98ff4b6e742a Mon Sep 17 00:00:00 2001
From: Dan Callaghan <dcallagh@redhat.com>
Date: Mon, 30 Jun 2014 11:27:56 +1000
Subject: [PATCH 2/2] script to run test.lua against a dummy slapd
diff --git a/lualdap/Makefile b/lualdap/Makefile
index 6a4f06d..101a07f 100755
--- a/lualdap/Makefile
+++ b/lualdap/Makefile
@@ -26,3 +26,6 @@ install: src/$(LIBNAME)
clean:
rm -f $(OBJS) src/$(LIBNAME)
+
+check:
+ LUA_CPATH="src/?.so.$V" tests/run-tests.sh
diff --git a/lualdap/tests/run-tests.sh b/lualdap/tests/run-tests.sh
new file mode 100755
index 0000000..22ac84b
--- /dev/null
+++ b/lualdap/tests/run-tests.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+set -ex
+
+d=$(readlink -f "$(dirname $0)")
+password=thepassword
+
+rm -rf "$d/slapd-config" "$d/slapd-data"
+mkdir "$d/slapd-config" "$d/slapd-data"
+
+# populate slapd config
+slapadd -F "$d/slapd-config" -n0 <<EOF
+dn: cn=config
+objectClass: olcGlobal
+cn: config
+olcPidFile: $d/slapd.pid
+
+dn: cn=schema,cn=config
+objectClass: olcSchemaConfig
+cn: schema
+
+include: file:///etc/openldap/schema/core.ldif
+include: file:///etc/openldap/schema/cosine.ldif
+include: file:///etc/openldap/schema/inetorgperson.ldif
+include: file:///etc/openldap/schema/nis.ldif
+
+dn: olcDatabase=config,cn=config
+objectClass: olcDatabaseConfig
+olcDatabase: config
+olcAccess: to * by * none
+
+dn: olcDatabase=bdb,cn=config
+objectClass: olcDatabaseConfig
+objectClass: olcBdbConfig
+olcDatabase: bdb
+olcSuffix: dc=example,dc=invalid
+olcDbDirectory: $d/slapd-data
+olcDbIndex: objectClass eq
+olcAccess: to * by * write
+#olcAccess: to * by users write
+EOF
+
+# populate slapd data
+slapadd -F "$d/slapd-config" -n1 <<EOF
+dn: dc=example,dc=invalid
+objectClass: top
+objectClass: domain
+
+#dn: ou=users,dc=example,dc=invalid
+#objectClass: top
+#objectClass: organizationalUnit
+#ou: users
+
+dn: uid=ldapuser,dc=example,dc=invalid
+objectClass: top
+objectClass: person
+objectClass: organizationalperson
+objectClass: inetorgperson
+objectClass: posixAccount
+cn: My LDAP User
+givenName: My
+sn: LDAP User
+uid: ldapuser
+uidNumber: 15549
+gidNumber: 15549
+homeDirectory: /home/lol
+mail: ldapuser@example.invalid
+userPassword: $(slappasswd -s "$password")
+EOF
+
+slapd -F "$d/slapd-config" -h ldap://localhost:3899/
+trap 'kill -TERM $(cat "$d/slapd.pid")' EXIT
+
+lua tests/test.lua localhost:3899 dc=example,dc=invalid uid=ldapuser,dc=example,dc=invalid "$password"
--
1.9.3

@ -9,7 +9,7 @@ diff -ur lualdap-1.1.0.orig/Makefile lualdap-1.1.0/Makefile
- cp src/$(LIBNAME) $(LUA_LIBDIR) - cp src/$(LIBNAME) $(LUA_LIBDIR)
- cd $(LUA_LIBDIR); ln -f -s $(LIBNAME) $T.so - cd $(LUA_LIBDIR); ln -f -s $(LIBNAME) $T.so
+ mkdir -p $(DESTDIR)$(LUA_LIBDIR) + mkdir -p $(DESTDIR)$(LUA_LIBDIR)
+ cp src/$(LIBNAME) $(DESTDIR)$(LUA_LIBDIR) + cp -p src/$(LIBNAME) $(DESTDIR)$(LUA_LIBDIR)
+ ln -s $(LIBNAME) $(DESTDIR)$(LUA_LIBDIR)/$T.so + ln -s $(LIBNAME) $(DESTDIR)$(LUA_LIBDIR)/$T.so
clean: clean:

@ -0,0 +1,35 @@
From 0d2e40bb182d8e417a5dac9000e5a5bb17422adf Mon Sep 17 00:00:00 2001
From: Dennis Schridde <devurandom@gmx.net>
Date: Thu, 31 May 2012 17:30:49 +0200
Subject: [PATCH] Fix potential Lua error (attempt to concatenate a nil value)
when ldap_parse_result returns a NULL error message
---
src/lualdap.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/lualdap.c b/src/lualdap.c
index 99c756e..d170038 100755
--- a/src/lualdap.c
+++ b/src/lualdap.c
@@ -436,10 +436,14 @@ static int result_message (lua_State *L) {
default:
lua_pushnil (L);
lua_pushliteral (L, LUALDAP_PREFIX);
- lua_pushstring (L, msg);
- lua_pushliteral (L, " ");
lua_pushstring (L, ldap_err2string(err));
- lua_concat (L, 4);
+ lua_concat (L, 2);
+ if (msg != NULL) {
+ lua_pushliteral (L, " (");
+ lua_pushstring (L, msg);
+ lua_pushliteral (L, ")");
+ lua_concat (L, 4);
+ }
ret = 2;
}
ldap_memfree (mdn);
--
1.9.3

@ -13,7 +13,7 @@
Name: lua-ldap Name: lua-ldap
Version: 1.1.0 Version: 1.1.0
Release: 1%{?dist} Release: 2%{?dist}
Summary: LDAP client library for Lua, using OpenLDAP Summary: LDAP client library for Lua, using OpenLDAP
License: MIT License: MIT
URL: http://www.keplerproject.org/lualdap/ URL: http://www.keplerproject.org/lualdap/
@ -22,13 +22,22 @@ Source0: http://files.luaforge.net/releases/lualdap/lualdap/LuaLDAP%{vers
Patch0: destdir.patch Patch0: destdir.patch
# fixes for Lua 5.2 compatibility # fixes for Lua 5.2 compatibility
Patch1: lua52.patch Patch1: lua52.patch
BuildRequires: lua-devel # https://github.com/luaforge/lualdap/commit/0d2e40bb182d8e417a5dac9000e5a5bb17422adf
BuildRequires: openldap-devel Patch2: fix-attempt-to-concatenate-a-nil-value.patch
# fix tests for Lua 5.2, make them runnable in the build
# https://github.com/luaforge/lualdap/pull/2
Patch3: 0001-update-test.lua-for-5.2.patch
Patch4: 0002-script-to-run-test.lua-against-a-dummy-slapd.patch
%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7 %if 0%{?fedora} >= 16 || 0%{?rhel} >= 7
Requires: lua(abi) = %{luaver} Requires: lua(abi) = %{luaver}
%else %else
Requires: lua >= %{luaver} Requires: lua >= %{luaver}
%endif %endif
BuildRequires: lua-devel
BuildRequires: openldap-devel
# for tests
BuildRequires: lua
BuildRequires: openldap-servers
%description %description
LuaLDAP is a simple interface from Lua to an LDAP client. It enables a Lua LuaLDAP is a simple interface from Lua to an LDAP client. It enables a Lua
@ -41,11 +50,7 @@ program to:
%package compat %package compat
Summary: LDAP client library for Lua 5.1, using OpenLDAP Summary: LDAP client library for Lua 5.1, using OpenLDAP
BuildRequires: compat-lua-devel >= %{luacompatver} BuildRequires: compat-lua-devel >= %{luacompatver}
%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7 Requires: lua(abi) = %{luacompatver}
Requires: lua(abi) = %{luacompatver}
%else
Requires: lua >= %{luacompatver}
%endif
%description compat %description compat
LuaLDAP is a simple interface from Lua to an LDAP client. It enables a Lua 5.1 LuaLDAP is a simple interface from Lua to an LDAP client. It enables a Lua 5.1
@ -59,18 +64,22 @@ program to:
%setup -q -n lualdap-%{version} %setup -q -n lualdap-%{version}
%patch0 -p1 %patch0 -p1
%patch1 -p1 %patch1 -p1
%patch2 -p1
%patch3 -p2
%patch4 -p2
chmod a+x tests/run-tests.sh
# LUA_VERSION_NUM is defined in lua.h, it shouldn't be set in config
echo "LUA_VERSION_NUM = " >>config
%if "%{?luacompatver}" %if "%{?luacompatver}"
rm -rf %{compatbuilddir} rm -rf %{compatbuilddir}
cp -a . %{compatbuilddir} cp -a . %{compatbuilddir}
%endif %endif
echo "CFLAGS = $RPM_OPT_FLAGS -fPIC -I%{_includedir} -DLDAP_DEPRECATED" >>config echo "CFLAGS = $RPM_OPT_FLAGS -fPIC -I%{_includedir} -DLDAP_DEPRECATED" >>config
echo "LUA_VERSION_NUM = $(subst .,,%{luaver})0" >>config
echo "LUA_LIBDIR = %{lualibdir}" >>config echo "LUA_LIBDIR = %{lualibdir}" >>config
%if "%{?luacompatver}" %if "%{?luacompatver}"
echo "CFLAGS = $RPM_OPT_FLAGS -fPIC -I%{_includedir}/lua-%{luacompatver} -DLDAP_DEPRECATED" >>%{compatbuilddir}/config echo "CFLAGS = $RPM_OPT_FLAGS -fPIC -I%{_includedir}/lua-%{luacompatver} -DLDAP_DEPRECATED" >>%{compatbuilddir}/config
echo "LUA_VERSION_NUM = $(subst .,,%{luacompatver})0" >>%{compatbuilddir}/config
echo "LUA_LIBDIR = %{luacompatlibdir}" >>%{compatbuilddir}/config echo "LUA_LIBDIR = %{luacompatlibdir}" >>%{compatbuilddir}/config
%endif %endif
@ -83,6 +92,9 @@ make %{?_smp_mflags}
popd popd
%endif %endif
%check
make check
%install %install
make install DESTDIR=%{buildroot} make install DESTDIR=%{buildroot}
@ -103,5 +115,8 @@ popd
%endif %endif
%changelog %changelog
* Mon Jun 30 2014 Dan Callaghan <dcallagh@redhat.com> - 1.1.0-2
- cp -p, run tests in %%check
* Thu Jun 05 2014 Dan Callaghan <dcallagh@redhat.com> - 1.1.0-1 * Thu Jun 05 2014 Dan Callaghan <dcallagh@redhat.com> - 1.1.0-1
- initial version - initial version

Loading…
Cancel
Save