diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..2b5037e --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,26 @@ +codecov: + notify: + require_ci_to_pass: yes + +coverage: + precision: 2 + round: down + range: "70...100" + + status: + project: yes + patch: yes + changes: no + +parsers: + gcov: + branch_detection: + conditional: yes + loop: yes + method: no + macro: no + +comment: + layout: "header, diff" + behavior: default + require_changes: no diff --git a/.gitignore b/.gitignore index 0d20b64..0570216 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.pyc +build/** diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..af36529 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +language: c +sudo: true + +env: + global: + - CODECOV_TOKEN=4792f32d-1685-4e2d-8cc4-b82e9578a605 + +before_install: + - sudo apt-get update -qq + - sudo apt-get install python-libxml2 libxml2-dev python-dev + +script: + - make GCOV=1 build + - make GCOV=1 unit + - find build/ -name '*.gcno' -exec mv {} ./ \; + - find build/ -name '*.gcda' -exec mv {} ./ \; + - make GCOV=1 dmidump + - sudo ./dmidump /dev/mem /dev/null + - make GCOV=1 version + +after_success: + - bash -- <(curl -s https://codecov.io/bash) -F unittest diff --git a/Makefile b/Makefile index 76d23de..73d2989 100644 --- a/Makefile +++ b/Makefile @@ -53,26 +53,37 @@ else endif SHELL := /bin/bash -############################################################################### -.PHONY: build dmidump install uninstall clean tarball rpm unit version +GCOV ?= 0 +CC_OPTS := -O2 +SETUP_PY_OPTS := +ifeq ($(GCOV),1) +CC_OPTS := -coverage -O0 -fprofile-arcs -ftest-coverage +SETUP_PY_OPTS := --gcov +endif -all : build dmidump +############################################################################### +.PHONY: all +all: build dmidump +.PHONY: build build: $(PY)-dmidecodemod.so $(PY)-dmidecodemod.so: $(SO) cp $< $@ $(SO): - $(PY) src/setup.py build + $(PY) src/setup.py $(SETUP_PY_OPTS) build -dmidump : src/util.o src/efi.o src/dmilog.o - $(CC) -o $@ src/dmidump.c $^ -g -Wall -D_DMIDUMP_MAIN_ +dmidump: src/util.o src/efi.o src/dmilog.o + $(CC) $(CC_OPTS) -o $@ src/dmidump.c $^ -g -Wall -D_DMIDUMP_MAIN_ +.PHONY: install install: $(PY) src/setup.py install +.PHONY: uninstall uninstall: $(PY) src/setup.py uninstall +.PHONY: clean clean: -$(PY) src/setup.py clean --all -rm -f *.so lib/*.o core dmidump src/*.o @@ -83,32 +94,38 @@ clean: -rm -rf $(PACKAGE)-$(VERSION) $(PACKAGE)-$(VERSION).tar.gz $(MAKE) -C unit-tests clean +.PHONY: tarball tarball: rm -rf $(PACKAGE)-$(VERSION) mkdir $(PACKAGE)-$(VERSION) cp -r contrib doc examples Makefile man README src dmidecode.py unit-tests/ $(PACKAGE)-$(VERSION) tar -czvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION) +.PHONY: rpm-prep rpm-prep: mkdir -p rpm/{BUILD,RPMS,SRPMS,SPECS,SOURCES} cp contrib/$(PACKAGE).spec rpm/SPECS cp $(PACKAGE)-$(VERSION).tar.gz rpm/SOURCES +.PHONY: rpm rpm: tarball rpm-prep rpmbuild -ba --define "_topdir $(shell pwd)/rpm" rpm/SPECS/$(PACKAGE).spec +.PHONY: rpm-md5 rpm-md5: tarball rpm-prep rpmbuild-md5 -ba --define "_topdir $(shell pwd)/rpm" rpm/SPECS/$(PACKAGE).spec +.PHONY: unit unit: $(MAKE) -C unit-tests +.PHONY: version version: @echo "python-dmidecode: $(VERSION)" @echo "python version: $(PY_VER) ($(PY))" +.PHONY: conflicts conflicts: @comm -12 \ <(dpkg-deb -c ../../DPKGS/python-dmidecode_$(VERSION)-1_amd64.deb | awk '$$NF!~/\/$$/{print$$NF}'|sort) \ <(dpkg-deb -c ../../DPKGS/python-dmidecode-dbg_$(VERSION)-1_amd64.deb | awk '$$NF!~/\/$$/{print$$NF}'|sort) - diff --git a/README b/README deleted file mode 100644 index 4892ef5..0000000 --- a/README +++ /dev/null @@ -1 +0,0 @@ -Please visit http://projects.autonomy.net.au/python-dmidecode/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..4215633 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Build Status + +| Branch | `travis.io` | `codecov.io` | +|------------|-------------|--------------| +| `master` | [![Build Status](https://travis-ci.org/nima/python-dmidecode.png?branch=master)](https://travis-ci.org/nima/python-dmidecode) || [![codecov](https://codecov.io/gh/nima/python-dmidecode/branch/master/graph/badge.svg)](https://codecov.io/gh/nima/python-dmidecode) | +| `develop` | [![Build Status](https://travis-ci.org/nima/python-dmidecode.png?branch=develop)](https://travis-ci.org/nima/python-dmidecode/branches) | [![codecov](https://codecov.io/gh/nima/python-dmidecode/branch/develop/graph/badge.svg)](https://codecov.io/gh/nima/python-dmidecode/branch/develop) | diff --git a/src/setup.py b/src/setup.py index aecad71..425fccf 100644 --- a/src/setup.py +++ b/src/setup.py @@ -43,6 +43,19 @@ # misc info dmidec_version = get_version() macros = get_macros() +compargs = [] +linkargs = [] + +# +# User arguments +# + +for token in sys.argv[:]: + if token == '--gcov': + macros.append( ('GCOV', 1) ) + compargs.extend([ '-coverage', '-O0', '-fprofile-arcs', '-ftest-coverage' ]) + linkargs.extend([ '-fprofile-arcs', '-lgcov' ]) + sys.argv.remove(token) # # Python setup @@ -60,7 +73,7 @@ ext_modules = [ Extension( "dmidecodemod", - sources = [ + sources = [ "src/dmidecodemodule.c", "src/util.c", "src/dmioem.c", @@ -74,9 +87,11 @@ ], include_dirs = incdir, library_dirs = libdir, - libraries = libs, + libraries = libs, undef_macros = [ "NDEBUG" ], - define_macros = macros + define_macros = macros, + extra_compile_args = compargs, + extra_link_args = linkargs, ) ], py_modules = [ "dmidecode" ]