summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <dfriesel@uos.de>2022-05-20 10:13:50 +0000
committerDaniel Friesel <dfriesel@uos.de>2022-05-20 10:13:50 +0000
commitdfd07b0a23396720e9bfe4515a596932694737ee (patch)
tree54ca7cb2b8748139fa534dcbdf40f7397ac72e7a
parent0daafbe96c1057fe7fd9cc64f3e74fb914c1eeb4 (diff)
parent4eb9358714cc5553c886021931752ec2b95055f4 (diff)
Merge branch 'feature/kconfig-benchmark-test' into 'master'
Add a test benchmark for explore-kconfig See merge request software/dfatool!2
-rw-r--r--.docker/Dockerfile25
-rwxr-xr-x.docker/mkdocker11
-rw-r--r--.gitlab-ci.yml22
-rw-r--r--examples/kconfig-static/Kconfig22
-rw-r--r--examples/kconfig-static/Makefile19
-rw-r--r--examples/kconfig-static/nfpkeys.json1
-rwxr-xr-xexamples/kconfig-static/nfpvalues.sh22
-rw-r--r--lib/kconfig.py28
8 files changed, 135 insertions, 15 deletions
diff --git a/.docker/Dockerfile b/.docker/Dockerfile
new file mode 100644
index 0000000..e65f6d8
--- /dev/null
+++ b/.docker/Dockerfile
@@ -0,0 +1,25 @@
+FROM debian:bullseye
+
+ARG DEBIAN_FRONTEND=noninteractive
+ARG APT_LISTCHANGES_FRONTEND=none
+
+RUN apt-get update \
+ && apt-get -y --no-install-recommends install \
+ ca-certificates \
+ kconfig-frontends-nox \
+ make \
+ python3-dev \
+ python3-coverage \
+ python3-frozendict \
+ python3-matplotlib \
+ python3-numpy \
+ python3-pytest \
+ python3-pytest-cov \
+ python3-scipy \
+ python3-sklearn \
+ python3-yaml \
+ python3-zbar \
+ wget \
+ && rm -rf /var/cache/apt/* /var/lib/apt/lists/*
+
+CMD ["bash"]
diff --git a/.docker/mkdocker b/.docker/mkdocker
new file mode 100755
index 0000000..9f72cc5
--- /dev/null
+++ b/.docker/mkdocker
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -e
+
+VERSION="$(date +%Y.%m.%d)"
+docker build -t ci-dfatool:${VERSION} .
+docker build -t ci-dfatool:latest .
+docker tag ci-dfatool:${VERSION} derfnull/ci-dfatool:${VERSION}
+docker tag ci-dfatool:latest derfnull/ci-dfatool:latest
+docker push derfnull/ci-dfatool:${VERSION}
+docker push derfnull/ci-dfatool:latest
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1e30111..d62d9e3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-image: debian:bullseye
+image: derfnull/ci-dfatool:2022.05.22
stages:
- test
@@ -10,8 +10,6 @@ run_tests:
variables:
GIT_SUBMODULE_STRATEGY: normal
script:
- - apt-get update -qy
- - apt-get install -y python3-dev python3-coverage python3-frozendict python3-numpy python3-scipy python3-pytest python3-pytest-cov python3-sklearn python3-yaml python3-zbar wget
- mkdir test-data
- wget -qO test-data/20161221_123347_mmparam.tar https://lib.finalrewind.org/energy-models/20161221_123347_mmparam.tar
- wget -qO test-data/20170116_124500_LM75x.tar https://lib.finalrewind.org/energy-models/20170116_124500_LM75x.tar
@@ -38,13 +36,26 @@ run_tests:
- htmlcov/
expire_in: 1 week
+make_benchmark:
+ stage: build
+ variables:
+ GIT_SUBMODULE_STRATEGY: normal
+ script:
+ - mkdir kconfig-static-data
+ - cd kconfig-static-data
+ - ../bin/explore-kconfig.py --log-level debug --random 5 --with-neighbourhood ${PWD}/../examples/kconfig-static
+ - DFATOOL_DTREE_IGNORE_IRRELEVANT_PARAMS=0 DFATOOL_KCONF_WITH_CHOICE_NODES=0 ../bin/analyze-kconfig.py --export-webconf example-static-rmt.json ../examples/kconfig-static/Kconfig .
+ - cp ../examples/kconfig-static/Kconfig example-static.kconfig
+ artifacts:
+ paths:
+ - example-static.kconfig
+ - example-static-rmt.json
+
make_model:
stage: build
variables:
GIT_SUBMODULE_STRATEGY: normal
script:
- - apt-get update -qy
- - apt-get install -y python3-dev python3-coverage python3-frozendict python3-numpy python3-scipy python3-sklearn python3-yaml python3-zbar wget
- wget -q https://ess.cs.uos.de/.private/dfatool/multipass.json.xz https://ess.cs.uos.de/.private/dfatool/multipass.kconfig
- DFATOOL_DTREE_IGNORE_IRRELEVANT_PARAMS=0 bin/analyze-kconfig.py multipass.kconfig multipass.json.xz --export-webconf multipass-rmt.json
- wget -q https://ess.cs.uos.de/.private/dfatool/x264.json.xz https://ess.cs.uos.de/.private/dfatool/x264.kconfig https://ess.cs.uos.de/.private/dfatool/x264.nfpkeys.json
@@ -60,6 +71,7 @@ make_model:
deploy_model:
stage: deploy
+ image: debian:bullseye
before_script:
- apt-get -y update
- apt-get -y install lftp
diff --git a/examples/kconfig-static/Kconfig b/examples/kconfig-static/Kconfig
new file mode 100644
index 0000000..1b02bac
--- /dev/null
+++ b/examples/kconfig-static/Kconfig
@@ -0,0 +1,22 @@
+choice
+prompt "pi or tau?"
+
+config X5
+bool "X = 5"
+
+config X6
+bool "X = 6"
+depends on !Y0
+
+endchoice
+
+choice
+prompt "apples or oranges?"
+
+config Y4
+bool "Y = 4"
+
+config Y0
+bool "Y = 0"
+
+endchoice
diff --git a/examples/kconfig-static/Makefile b/examples/kconfig-static/Makefile
new file mode 100644
index 0000000..9e56c12
--- /dev/null
+++ b/examples/kconfig-static/Makefile
@@ -0,0 +1,19 @@
+default:
+ @true
+
+config:
+ kconfig-qconf Kconfig
+
+randconfig:
+ kconfig-conf --randconfig Kconfig
+
+clean:
+ @true
+
+nfpvalues:
+ @./nfpvalues.sh
+
+nfpkeys:
+ @cat nfpkeys.json
+
+.PHONY: default config randconfig clean nfpvalues nfpkeys
diff --git a/examples/kconfig-static/nfpkeys.json b/examples/kconfig-static/nfpkeys.json
new file mode 100644
index 0000000..82a3e7f
--- /dev/null
+++ b/examples/kconfig-static/nfpkeys.json
@@ -0,0 +1 @@
+{"Synthetic": {"X": {"unit": "apples", "description": "NFP X", "minimize": true}, "Y": {"unit": "oranges", "description": "NFP Y", "minimize": true}}}
diff --git a/examples/kconfig-static/nfpvalues.sh b/examples/kconfig-static/nfpvalues.sh
new file mode 100755
index 0000000..574aa47
--- /dev/null
+++ b/examples/kconfig-static/nfpvalues.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+. ./.config
+
+X=0
+Y=0
+
+if [ "$CONFIG_X5" = y ]; then
+ X=5
+fi
+if [ "$CONFIG_X6" = y ]; then
+ X=6
+fi
+
+if [ "$CONFIG_Y0" = y ]; then
+ Y=0
+fi
+if [ "$CONFIG_Y4" = y ]; then
+ Y=4
+fi
+
+echo '{"Synthetic": {"X": '$X', "Y": '$Y'}}'
diff --git a/lib/kconfig.py b/lib/kconfig.py
index 3a402ad..fe077a5 100644
--- a/lib/kconfig.py
+++ b/lib/kconfig.py
@@ -108,15 +108,18 @@ class KConfig:
return "unknown"
def git_commit_id(self):
- status = subprocess.run(
- ["git", "rev-parse", "HEAD"],
- cwd=self.cwd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- universal_newlines=True,
- )
- revision = status.stdout.strip()
- return revision
+ try:
+ status = subprocess.run(
+ ["git", "rev-parse", "HEAD"],
+ cwd=self.cwd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ universal_newlines=True,
+ )
+ revision = status.stdout.strip()
+ return revision
+ except FileNotFoundError:
+ return "unknown"
def file_hash(self, config_file):
status = subprocess.run(
@@ -126,7 +129,12 @@ class KConfig:
stderr=subprocess.PIPE,
universal_newlines=True,
)
- sha256sum = status.stdout.split()[0]
+ try:
+ sha256sum = status.stdout.split()[0]
+ except IndexError:
+ raise RuntimeError(
+ f"Unable to extract hash from 'sha256sum {config_file}' output '{status.stdout}'"
+ )
return sha256sum
def run_nfpkeys(self):