parse_spec unittest
authorhwangx <huix.wang@intel.com>
Thu, 29 Mar 2012 06:34:25 +0000 (14:34 +0800)
committerhwangx <huix.wang@intel.com>
Thu, 29 Mar 2012 07:34:25 +0000 (15:34 +0800)
tests/03_test_utils_parsespec.py [new file with mode: 0644]
tests/testdata/bluez.spec [new file with mode: 0644]

diff --git a/tests/03_test_utils_parsespec.py b/tests/03_test_utils_parsespec.py
new file mode 100644 (file)
index 0000000..861cda7
--- /dev/null
@@ -0,0 +1,27 @@
+# vim: set fileencoding=utf-8 :
+#
+# check if --help works
+
+import os
+import unittest
+from gitbuildsys import utils
+
+class TestParseSpec(unittest.TestCase):
+    """Test utils.parse_spec of gbs function"""
+    spec_path = 'tests/testdata/bluez.spec'
+    def testParseSpecGoodInput(self):
+        valid_keys = ('Name', 'Version', 'Release', 'Summary', 'Description', 'License',
+                       'Group', 'Url', 'Os', 'Arch', 'Requireflags', 'Requirename', 'Requireversion',
+                       'Platform', 'build', 'buildRoot', 'clean', 'install', 'prep','source0', 'patch0')
+       valid_keys2 = (100, 1000, 1001, 1002, 1004, 1005, 1014, 1016, 1020, 1021, 1022, 1048, 1049, 1050, 1132)
+        for s in valid_keys:
+            ret = utils.parse_spec(self.spec_path, s)
+            self.assertNotEqual(ret, '')
+        for s in valid_keys2:
+            ret = utils.parse_spec(self.spec_path, s)
+            self.assertNotEqual(ret, '')
+    def testParseSpecBadInput(self):
+        invalid_keys = ('names', 'versions', 'test', 'source1000', 'source', 'patch1000', 'patchs','patch-source0',
+                       '', [], {}, 101, 1003)
+       for s in invalid_keys:
+           self.assertRaises(Exception, utils.parse_spec, self.spec_path, s)
diff --git a/tests/testdata/bluez.spec b/tests/testdata/bluez.spec
new file mode 100644 (file)
index 0000000..072cf16
--- /dev/null
@@ -0,0 +1,290 @@
+# 
+# Do NOT Edit the Auto-generated Part!
+# Generated by: spectacle version 0.21
+# 
+# >> macros
+# << macros
+
+Name:       bluez
+Summary:    Bluetooth utilities
+Version:    4.87
+Release:    1
+Group:      Applications/System
+License:    GPLv2+
+URL:        http://www.bluez.org/
+Source0:    http://www.kernel.org/pub/linux/bluetooth/%{name}-%{version}-tizen.tar.bz2
+Source1:    bluetooth.init
+Source100:  bluez.yaml
+Patch0:     bluez-fsync.patch
+Patch1:     remove-duplicate-wrong-udev-rule-for-dell-mice.patch
+Patch2:     enable_HFP.patch
+Patch3:     powered.patch
+Patch4:     install-test-scripts.patch
+Patch5:     install-more-binary-test.patch
+Patch6:     disable-hal-plugin.patch
+Requires:   bluez-libs = %{version}
+Requires:   dbus >= 0.60
+Requires:   hwdata >= 0.215
+Requires:   ofono >= 0.2
+Requires(post): /sbin/service
+Requires(post): /sbin/chkconfig
+Requires(postun): /sbin/service
+Requires(postun): /sbin/chkconfig
+BuildRequires:  pkgconfig(dbus-1)
+BuildRequires:  pkgconfig(libusb)
+BuildRequires:  pkgconfig(alsa)
+BuildRequires:  pkgconfig(udev)
+BuildRequires:  pkgconfig(sndfile)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(gstreamer-plugins-base-0.10)
+BuildRequires:  pkgconfig(gstreamer-0.10)
+BuildRequires:  flex
+
+
+%description
+Utilities for use in Bluetooth applications:
+       --ciptool
+       --dfutool
+       --hcitool
+       --l2ping
+       --rfcomm
+       --sdptool
+       --hciattach
+       --hciconfig
+       --hid2hci
+
+The BLUETOOTH trademarks are owned by Bluetooth SIG, Inc., U.S.A.
+
+
+
+%package libs
+Summary:    Libraries for use in Bluetooth applications
+Group:      System/Libraries
+Requires:   %{name} = %{version}-%{release}
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description libs
+Libraries for use in Bluetooth applications.
+
+%package libs-devel
+Summary:    Development libraries for Bluetooth applications
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+Requires:   bluez-libs = %{version}
+
+%description libs-devel
+bluez-libs-devel contains development libraries and headers for
+use in Bluetooth applications.
+
+
+%package cups
+Summary:    CUPS printer backend for Bluetooth printers
+Group:      System/Daemons
+Requires:   %{name} = %{version}-%{release}
+Requires:   bluez-libs = %{version}
+Requires:   cups
+
+%description cups
+This package contains the CUPS backend
+
+%package alsa
+Summary:    ALSA support for Bluetooth audio devices
+Group:      System/Daemons
+Requires:   %{name} = %{version}-%{release}
+Requires:   bluez-libs = %{version}
+
+%description alsa
+This package contains ALSA support for Bluetooth audio devices
+
+%package gstreamer
+Summary:    GStreamer support for SBC audio format
+Group:      System/Daemons
+Requires:   %{name} = %{version}-%{release}
+Requires:   bluez-libs = %{version}
+
+%description gstreamer
+This package contains gstreamer plugins for the Bluetooth SBC audio format
+
+%package test
+Summary:    Test Programs for BlueZ
+Group:      Development/Tools
+Requires:   %{name} = %{version}-%{release}
+Requires:   bluez-libs = %{version}
+Requires:   dbus-python
+Requires:   pygobject2
+
+%description test
+Scripts for testing BlueZ and its functionality
+
+
+%prep
+%setup -q -n %{name}-%{version}
+
+# bluez-fsync.patch
+%patch0 -p1
+# remove-duplicate-wrong-udev-rule-for-dell-mice.patch
+%patch1 -p1
+# enable_HFP.patch
+%patch2 -p1
+# powered.patch
+%patch3 -p1
+# install-test-scripts.patch
+%patch4 -p1
+# install-more-binary-test.patch
+%patch5 -p1
+# disable-hal-plugin.patch
+%patch6 -p1
+# >> setup
+# << setup
+
+%build
+# >> build pre
+# << build pre
+
+%reconfigure --disable-static \
+    --enable-cups \
+    --enable-hid2hci \
+    --enable-dfutool \
+    --enable-bccmd \
+    --enable-hidd \
+    --enable-pand \
+    --enable-dund \
+    --enable-gstreamer \
+    --enable-alsa \
+    --enable-usb \
+    --enable-tools \
+    --enable-test \
+    --with-telephony=dummy
+
+make %{?jobs:-j%jobs}
+
+# >> build post
+# << build post
+%install
+rm -rf %{buildroot}
+# >> install pre
+# << install pre
+%make_install
+
+# >> install post
+
+install -D -m0755 %SOURCE1 $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/bluetooth
+
+# Remove the cups backend from libdir, and install it in /usr/lib whatever the install
+rm -rf ${RPM_BUILD_ROOT}%{_libdir}/cups
+install -D -m0755 cups/bluetooth ${RPM_BUILD_ROOT}/usr/lib/cups/backend/bluetooth
+
+install -d -m0755 $RPM_BUILD_ROOT/%{_localstatedir}/lib/bluetooth
+
+# << install post
+
+
+
+
+
+
+
+%post libs -p /sbin/ldconfig
+
+%postun libs -p /sbin/ldconfig
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+%files
+%defattr(-,root,root,-)
+# >> files
+%defattr(-, root, root)
+%{_bindir}/ciptool
+%{_bindir}/dfutool
+%{_bindir}/dund
+%{_bindir}/hcitool
+%{_bindir}/hidd
+%{_bindir}/l2ping
+%{_bindir}/pand
+%{_bindir}/rfcomm
+%{_bindir}/sdptool
+%{_sbindir}/*
+%doc %{_mandir}/man1/*
+%doc %{_mandir}/man8/*
+%config(noreplace) %{_sysconfdir}/bluetooth/*
+%config %{_sysconfdir}/dbus-1/system.d/bluetooth.conf
+%exclude /etc/rc.d/init.d/*
+%{_localstatedir}/lib/bluetooth
+/lib/udev/*
+# << files
+
+
+%files libs
+%defattr(-,root,root,-)
+# >> files libs
+%defattr(-, root, root)
+%{_libdir}/libbluetooth.so.*
+%doc AUTHORS COPYING INSTALL README
+# << files libs
+
+%files libs-devel
+%defattr(-,root,root,-)
+# >> files libs-devel
+%defattr(-, root, root)
+%{_libdir}/libbluetooth.so
+%dir %{_includedir}/bluetooth
+%{_includedir}/bluetooth/*
+%{_libdir}/pkgconfig/bluez.pc
+# << files libs-devel
+
+%files cups
+%defattr(-,root,root,-)
+# >> files cups
+%defattr(-, root, root)
+/usr/lib/cups/backend/bluetooth
+# << files cups
+
+%files alsa
+%defattr(-,root,root,-)
+# >> files alsa
+%defattr(-, root, root)
+%{_libdir}/alsa-lib/*.so
+%{_datadir}/alsa/bluetooth.conf
+# << files alsa
+
+%files gstreamer
+%defattr(-,root,root,-)
+# >> files gstreamer
+%defattr(-, root, root)
+%{_libdir}/gstreamer-*/*.so
+# << files gstreamer
+
+%files test
+%defattr(-,root,root,-)
+# >> files test
+%{_libdir}/%{name}/test/*
+%{_bindir}/hstest
+%{_bindir}/gaptest
+%{_bindir}/sdptest
+%{_bindir}/l2test
+%{_bindir}/btiotest
+%{_bindir}/avtest
+%{_bindir}/bdaddr
+%{_bindir}/scotest
+%{_bindir}/lmptest
+%{_bindir}/attest
+%{_bindir}/agent
+%{_bindir}/test-textfile
+%{_bindir}/rctest
+%{_bindir}/ipctest
+# << files test
+