Compare commits
No commits in common. "c8" and "c9s" have entirely different histories.
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,2 @@
|
||||
SOURCES/libconfig-1.5.tar.gz
|
||||
SOURCES/libconfig.pdf
|
||||
/libconfig-1.7.2.pdf
|
||||
/libconfig-1.7.2.tar.gz
|
||||
|
@ -1,2 +0,0 @@
|
||||
24306c7efce07669a4053d0977a45e2f3a3add79 SOURCES/libconfig-1.5.tar.gz
|
||||
0a844d17022a58df84d93d9fe4de90b1c9ffb197 SOURCES/libconfig.pdf
|
30
generate-pdf.sh
Executable file
30
generate-pdf.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#! /bin/sh
|
||||
|
||||
# This script builds the PDF version of the libconfig documentation.
|
||||
# Inspired by the PostgreSQL package.
|
||||
|
||||
set -e
|
||||
|
||||
# Pass package version and name optionally as argument
|
||||
VERSION=$1
|
||||
PKGNAME=${2-libconfig}
|
||||
|
||||
test -z "$VERSION" && VERSION=`awk '/^Version:/ { print $2; }' "$PKGNAME".spec`
|
||||
|
||||
TARGETFILE=`readlink -f "$PKGNAME-$VERSION.pdf"`
|
||||
test -f "$TARGETFILE" && echo "$TARGETFILE exists" && exit 1
|
||||
|
||||
echo Building $TARGETFILE ...
|
||||
|
||||
tar xf "$PKGNAME"-$VERSION.tar.*
|
||||
cd "$PKGNAME"-$VERSION
|
||||
|
||||
# Apply any patches that affect the PDF documentation
|
||||
# patch -p1 < ../xxx.patch
|
||||
|
||||
# Build the PDF docs
|
||||
./configure >/dev/null
|
||||
make pdf
|
||||
mv -f doc/libconfig.pdf "$TARGETFILE"
|
||||
|
||||
exit 0
|
@ -1,15 +1,21 @@
|
||||
%bcond_without check
|
||||
|
||||
Name: libconfig
|
||||
Summary: C/C++ configuration file library
|
||||
Version: 1.5
|
||||
Version: 1.7.2
|
||||
Release: 9%{?dist}
|
||||
License: LGPLv2+
|
||||
Group: System Environment/Libraries
|
||||
Source0: http://www.hyperrealm.com/libconfig/libconfig-%{version}.tar.gz
|
||||
# Generated from libconfig 1.5 on Fedora 23 x86_64 (2015-12-17)
|
||||
Source1: libconfig.pdf
|
||||
URL: http://www.hyperrealm.com/libconfig/
|
||||
BuildRequires: texinfo-tex, tex(ecbx1095.tfm), tex(ecrm1095.tfm), tex(cm-super-t1.enc)
|
||||
BuildRequires: bison, flex
|
||||
Source0: https://hyperrealm.github.io/%name/dist/%name-%version.tar.gz
|
||||
# Generated from libconfig 1.7.2 on Fedora 28 x86_64 (2018-07-18)
|
||||
Source1: libconfig-%version.pdf
|
||||
# Helper script to generate Source1 (locally)
|
||||
Source2: generate-pdf.sh
|
||||
|
||||
BuildRequires: gcc, gcc-c++
|
||||
BuildRequires: texinfo
|
||||
BuildRequires: bison, flex
|
||||
BuildRequires: make
|
||||
|
||||
%description
|
||||
Libconfig is a simple library for manipulating structured configuration
|
||||
@ -17,61 +23,102 @@ files. This file format is more compact and more readable than XML. And
|
||||
unlike XML, it is type-aware, so it is not necessary to do string parsing
|
||||
in application code.
|
||||
|
||||
|
||||
%package devel
|
||||
Summary: Development files for libconfig
|
||||
Group: Development/Libraries
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
Requires: pkgconfig
|
||||
Requires(post): /sbin/install-info
|
||||
Requires(preun): /sbin/install-info
|
||||
Requires: %{name}%{?_isa} = %{version}-%{release}
|
||||
|
||||
%description devel
|
||||
Development libraries and headers for developing software against
|
||||
libconfig.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
iconv -f iso-8859-1 -t utf-8 -o AUTHORS{.utf8,}
|
||||
mv AUTHORS{.utf8,}
|
||||
|
||||
|
||||
%build
|
||||
%configure --disable-static
|
||||
%configure \
|
||||
--disable-silent-rules \
|
||||
--disable-static
|
||||
|
||||
make %{?_smp_mflags}
|
||||
make pdf
|
||||
|
||||
|
||||
%install
|
||||
make DESTDIR=$RPM_BUILD_ROOT install
|
||||
%make_install
|
||||
rm -rf $RPM_BUILD_ROOT%{_libdir}/*.la
|
||||
rm -rf $RPM_BUILD_ROOT%{_infodir}/dir
|
||||
# Need to use a pre-built copy to support multilib
|
||||
rm -rf doc/libconfig.pdf
|
||||
install -p %{SOURCE1} doc/
|
||||
|
||||
|
||||
%if %{with check}
|
||||
%check
|
||||
./tests/libconfig_tests
|
||||
make check
|
||||
%endif
|
||||
|
||||
|
||||
%ldconfig_scriptlets
|
||||
|
||||
%post devel
|
||||
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :
|
||||
|
||||
%preun devel
|
||||
if [ $1 = 0 ]; then
|
||||
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
|
||||
fi
|
||||
|
||||
%files
|
||||
%doc AUTHORS ChangeLog COPYING.LIB README
|
||||
%{_libdir}/libconfig*.so.*
|
||||
%license COPYING.LIB
|
||||
%doc AUTHORS ChangeLog README
|
||||
%{_libdir}/libconfig*.so.11*
|
||||
|
||||
|
||||
%files devel
|
||||
%doc doc/libconfig.pdf
|
||||
%doc doc/libconfig-%version.pdf
|
||||
%{_includedir}/libconfig*
|
||||
%{_libdir}/cmake/%{name}
|
||||
%{_libdir}/cmake/%{name}++
|
||||
%{_libdir}/libconfig*.so
|
||||
%{_libdir}/pkgconfig/libconfig*.pc
|
||||
%{_infodir}/libconfig.info*
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.7.2-9
|
||||
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
|
||||
Related: rhbz#1991688
|
||||
|
||||
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.7.2-8
|
||||
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
|
||||
|
||||
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.2-7
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||
|
||||
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.2-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||
|
||||
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.2-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||
|
||||
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.2-4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.2-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||
|
||||
* Tue Jul 24 2018 Rex Dieter <rdieter@fedoraproject.org> - 1.7.2-2
|
||||
- %%files: track library sonames, so bumps aren't a surprise
|
||||
- %%build: --disable-silent-rules
|
||||
- -devel: tighten subpkg dep with %%_isa, drop hard-coded pkgconfig dep
|
||||
- use %%make_build %%make_install %%ldconfig_scriptlets
|
||||
|
||||
* Mon Jul 23 2018 Pavel Raiskup <praiskup@redhat.com> - 1.7.2-1
|
||||
- new upstream release (rhbz#1602423)
|
||||
|
||||
* Mon Jul 23 2018 Pavel Raiskup <praiskup@redhat.com> - 1.5-12
|
||||
- cleanup
|
||||
|
||||
* Sun Jul 22 2018 Peter Robinson <pbrobinson@fedoraproject.org> 1.5-11
|
||||
- Add missing gcc-c++ dep, spec cleanups
|
||||
|
||||
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.5-10
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
|
||||
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.5-9
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
||||
|
2
sources
Normal file
2
sources
Normal file
@ -0,0 +1,2 @@
|
||||
SHA512 (libconfig-1.7.2.tar.gz) = b0fcc403325fde217bd6509f10e8458958c8a93ff0a400da2602d62b7873e87f43ee6f1763ba30b3316e35a282a766c781a94b4d021b8c7e6ae2cf2cf108dd84
|
||||
SHA512 (libconfig-1.7.2.pdf) = d956be4f0300a1a1343694f1d2ef0943318455940de44f77347619583f1d3077c7dd12609b95a5f4b9fc4068067b492a48e743bd706f17da7381f8122400e8b6
|
46
tests/sanity-tests/Makefile
Normal file
46
tests/sanity-tests/Makefile
Normal file
@ -0,0 +1,46 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1+
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /CoreOS/libconfig
|
||||
# Description: Test if libconfig working ok
|
||||
# Author: Susant Sahani<susant@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
export TEST=/CoreOS/libconfig
|
||||
export TESTVERSION=1.0
|
||||
|
||||
OBJS = test-libconfig.c
|
||||
CFLAG = -Wall -g3
|
||||
CC = gcc
|
||||
LIBS = -lconfig -lcmocka
|
||||
|
||||
test-libconfig:${OBJ}
|
||||
${CC} ${CFLAGS} ${INCLUDES} -o $@ ${OBJS} ${LIBS}
|
||||
|
||||
run: test-libconfig
|
||||
./runtest.sh
|
||||
clean:
|
||||
-rm -f *~ test-libconfig
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} ${INCLUDES} -c $<
|
||||
|
||||
CC = gcc
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Susant Sahani<susant@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Test libconfig works ok" >> $(METADATA)
|
||||
@echo "Type: Sanity" >> $(METADATA)
|
||||
@echo "TestTime: 5m" >> $(METADATA)
|
||||
@echo "RunFor: libconfig" >> $(METADATA)
|
||||
@echo "Requires: libconfig libconfig-devel" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
@echo "Releases: -Fedora 29" >> $(METADATA)
|
||||
rhts-lint $(METADATA)
|
11
tests/sanity-tests/auth.cfg
Normal file
11
tests/sanity-tests/auth.cfg
Normal file
@ -0,0 +1,11 @@
|
||||
# authenticator
|
||||
|
||||
name = "JP";
|
||||
enabled = false;
|
||||
length = 186;
|
||||
|
||||
ldap = {
|
||||
host = "ldap.example.com";
|
||||
base = "ou=usr,o=example.com"; /* adapt this */
|
||||
retries = [10, 15, 20, 60]; // Use more than 2
|
||||
};
|
35
tests/sanity-tests/runtest.sh
Executable file
35
tests/sanity-tests/runtest.sh
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1+
|
||||
# ~~~
|
||||
# runtest.sh of libconfig
|
||||
# Description: Tests for libconfig
|
||||
#
|
||||
# Author: Susant Sahani <susant@redhat.com>
|
||||
# Copyright (c) 2018 Red Hat, Inc.
|
||||
# ~~~
|
||||
|
||||
# Include Beaker environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGE="libconfig"
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm $PACKAGE
|
||||
rlRun "cp test-libconfig /usr/bin/"
|
||||
rlRun "cp auth.cfg /var/run/"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlLog "Starting libconfig tests ..."
|
||||
rlRun "/usr/bin/test-libconfig"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "rm /usr/bin/test-libconfig /var/run/auth.cfg"
|
||||
rlLog "libconfig tests done"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
||||
|
||||
rlGetTestState
|
131
tests/sanity-tests/test-libconfig.c
Normal file
131
tests/sanity-tests/test-libconfig.c
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
# SPDX-License-Identifier: LGPL-2.1+
|
||||
# ~~~
|
||||
# Description: libconfig
|
||||
#
|
||||
# Author: Susant Sahani <susant@redhat.com>
|
||||
# Copyright (c) 2018 Red Hat, Inc.
|
||||
# ~~~
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <netinet/in.h>
|
||||
#include <setjmp.h>
|
||||
#include <inttypes.h>
|
||||
#include <cmocka.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libconfig.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define TEST_WRITE_FILE_NAME "/var/run/example.cfg"
|
||||
#define TEST_READ_FILE_NAME "/var/run/auth.cfg"
|
||||
|
||||
static void test_config_read(void **state) {
|
||||
const char *base = NULL, *host = NULL, *name = NULL;
|
||||
const config_setting_t *retries;
|
||||
int aretries[] = {10, 15, 20, 60};
|
||||
int count, n, enabled;
|
||||
config_t cfg, *cf;
|
||||
|
||||
cf = &cfg;
|
||||
config_init(cf);
|
||||
|
||||
assert_non_null(config_read_file(cf, TEST_READ_FILE_NAME));
|
||||
|
||||
assert_true(config_lookup_string(cf, "name", &name) >=0);
|
||||
assert_string_equal(name, "JP");
|
||||
|
||||
assert_true(config_lookup_bool(cf, "enabled", &enabled) >=0);
|
||||
assert_int_equal(enabled, 0);
|
||||
|
||||
assert_true((config_lookup_string(cf, "ldap.host", &host)) >=0);
|
||||
assert_string_equal(host, "ldap.example.com");
|
||||
|
||||
assert_true((config_lookup_string(cf, "ldap.base", &base)) >=0);
|
||||
assert_string_equal(base , "ou=usr,o=example.com");
|
||||
|
||||
assert_non_null((retries = config_lookup(cf, "ldap.retries")));
|
||||
count = config_setting_length(retries);
|
||||
|
||||
assert_int_equal(count, 4);
|
||||
for (n = 0; n < count; n++)
|
||||
assert_int_equal(aretries[n], config_setting_get_int_elem(retries, n));
|
||||
|
||||
config_destroy(cf);
|
||||
}
|
||||
|
||||
static void test_config_write(void **state) {
|
||||
config_setting_t *root, *setting, *group, *array;
|
||||
const char *street, *city, *st, *str;
|
||||
config_t cfg, *cf;
|
||||
int i, zip;
|
||||
|
||||
config_init(&cfg);
|
||||
root = config_root_setting(&cfg);
|
||||
|
||||
assert_non_null((group = config_setting_add(root, "address", CONFIG_TYPE_GROUP)));
|
||||
|
||||
assert_non_null((setting = config_setting_add(group, "street", CONFIG_TYPE_STRING)));
|
||||
assert_true(config_setting_set_string(setting, "1 Woz Way") >= 0);
|
||||
|
||||
assert_non_null((setting = config_setting_add(group, "city", CONFIG_TYPE_STRING)));
|
||||
assert_true(config_setting_set_string(setting, "San Jose") >= 0);
|
||||
|
||||
assert_non_null((setting = config_setting_add(group, "state", CONFIG_TYPE_STRING)));
|
||||
assert_true(config_setting_set_string(setting, "CA") >= 0);
|
||||
|
||||
assert_non_null((setting = config_setting_add(group, "zip", CONFIG_TYPE_INT)));
|
||||
assert_true(config_setting_set_int(setting, 95110) >= 0);
|
||||
|
||||
assert_non_null((array = config_setting_add(root, "numbers", CONFIG_TYPE_ARRAY)));
|
||||
|
||||
for(i = 0; i < 10; ++i) {
|
||||
assert_non_null((setting = config_setting_add(array, NULL, CONFIG_TYPE_INT)));
|
||||
assert_true(config_setting_set_int(setting, 10 * i) >=0);
|
||||
}
|
||||
|
||||
assert_non_null((config_write_file(&cfg, TEST_WRITE_FILE_NAME)));
|
||||
config_destroy(&cfg);
|
||||
|
||||
/* Read Back and test */
|
||||
config_init(&cfg);
|
||||
|
||||
assert_non_null((config_read_file(&cfg, TEST_WRITE_FILE_NAME)));
|
||||
assert_non_null((setting = config_lookup(&cfg, "address")));
|
||||
|
||||
assert_true(config_setting_lookup_string(setting, "street", &street) >= 0);
|
||||
assert_string_equal(street, "1 Woz Way");
|
||||
|
||||
assert_true(config_setting_lookup_string(setting, "city", &city) >=0);
|
||||
assert_string_equal(city, "San Jose");
|
||||
|
||||
assert_true(config_setting_lookup_string(setting, "state", &st) >=0);
|
||||
assert_string_equal(st, "CA");
|
||||
|
||||
assert_true(config_setting_lookup_int(setting, "zip", &zip) >=0);
|
||||
assert_int_equal(zip, 95110);
|
||||
|
||||
array = config_lookup(&cfg, "numbers");
|
||||
if(array) {
|
||||
int count, n;
|
||||
|
||||
count = config_setting_length(array);
|
||||
for (n = 0; n < count; n++) {
|
||||
assert_int_equal(n * 10, config_setting_get_int_elem(array, n));
|
||||
}
|
||||
}
|
||||
config_destroy(&cfg);
|
||||
|
||||
unlink(TEST_WRITE_FILE_NAME);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
const struct CMUnitTest libconfig_tests[] = {
|
||||
cmocka_unit_test(test_config_write),
|
||||
cmocka_unit_test(test_config_read),
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(libconfig_tests, NULL, NULL);
|
||||
}
|
13
tests/tests.yml
Normal file
13
tests/tests.yml
Normal file
@ -0,0 +1,13 @@
|
||||
- hosts: localhost
|
||||
roles:
|
||||
- role: standard-test-beakerlib
|
||||
tags:
|
||||
- classic
|
||||
tests:
|
||||
- sanity-tests
|
||||
required_packages:
|
||||
- libconfig
|
||||
- libconfig-devel
|
||||
- libcmocka
|
||||
- libcmocka-devel
|
||||
- gcc
|
Loading…
Reference in New Issue
Block a user