[Skiboot] [PATCH 3/5] hdata_to_dt: Only output dtb

Oliver O'Halloran oohall at gmail.com
Fri Feb 10 13:12:51 AEDT 2017


From: Stewart Smith <stewart at linux.vnet.ibm.com>

convert test cases to diff DTS rather than DTB.

This means we also have to build dtc on CentOS 7 to be able to run
the test suite.

Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
[oohall at gmail.com moved the test cases into seperate patches]
---
 hdata/test/Makefile.check         |  8 +++----
 hdata/test/hdata_to_dt.c          | 50 +++++++++++++--------------------------
 hdata/test/stubs.c                |  2 +-
 opal-ci/Dockerfile-centos6        |  2 +-
 opal-ci/Dockerfile-centos7        |  5 +++-
 opal-ci/Dockerfile-fedora-rawhide |  2 +-
 opal-ci/Dockerfile-fedora24       |  2 +-
 opal-ci/Dockerfile-fedora25       |  2 +-
 opal-ci/Dockerfile-ubuntu-12.04   |  2 +-
 opal-ci/Dockerfile-ubuntu-16.04   |  2 +-
 opal-ci/Dockerfile-ubuntu-latest  |  2 +-
 test/dt_common.c                  |  4 +++-
 12 files changed, 35 insertions(+), 48 deletions(-)

diff --git a/hdata/test/Makefile.check b/hdata/test/Makefile.check
index 8318eab9630f..45c0a4ef6ce4 100644
--- a/hdata/test/Makefile.check
+++ b/hdata/test/Makefile.check
@@ -20,14 +20,14 @@ hdata/test/hdata_to_dt-check-q: hdata/test/hdata_to_dt
 	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -s -q hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras, $<)
 
 hdata/test/hdata_to_dt-check-dt: hdata/test/hdata_to_dt
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt hdata/test/p81-811.spira hdata/test/p81-811.spira.heap |diff -u hdata/test/p81-811.spira.dt -, $< device-tree)
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -s hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras |diff -u hdata/test/p8-840-spira.dt -, $< device-tree)
+	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt hdata/test/p81-811.spira hdata/test/p81-811.spira.heap 2>/dev/null |dtc -I dtb -O dts |diff -u hdata/test/p81-811.spira.dts -, $< device-tree)
+	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -s hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras 2>/dev/null |dtc -I dtb -O dts |diff -u hdata/test/p8-840-spira.dts -, $< device-tree)
 
 hdata/test/hdata_to_dt-gcov-run: hdata/test/hdata_to_dt-check-dt-gcov-run
 
 hdata/test/hdata_to_dt-check-dt-gcov-run: hdata/test/hdata_to_dt-gcov
-	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt-gcov hdata/test/p81-811.spira hdata/test/p81-811.spira.heap |diff -u hdata/test/p81-811.spira.dt -, $< device-tree)
-	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt-gcov -s hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras |diff -u hdata/test/p8-840-spira.dt -, $< device-tree)
+	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt-gcov hdata/test/p81-811.spira hdata/test/p81-811.spira.heap 2>/dev/null |dtc -I dtb -O dts|diff -u hdata/test/p81-811.spira.dts -, $< device-tree)
+	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt-gcov -s hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras 2>/dev/null |dtc -I dtb -O dts|diff -u hdata/test/p8-840-spira.dts -, $< device-tree)
 
 hdata/test/stubs.o: hdata/test/stubs.c
 	$(call Q, HOSTCC , $(HOSTCC) $(HOSTCFLAGS) -g -c -o $@ $<, $<)
diff --git a/hdata/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c
index 113887aca08f..85733196ad10 100644
--- a/hdata/test/hdata_to_dt.c
+++ b/hdata/test/hdata_to_dt.c
@@ -197,10 +197,9 @@ static void squash_blobs(struct dt_node *root)
 		squash_blobs(n);
 }
 
-static void dump_hdata_fdt(struct dt_node *root, const char *filename)
+static void dump_hdata_fdt(struct dt_node *root)
 {
 	void *fdt_blob;
-	FILE *f;
 
 	fdt_blob = create_dtb(root, false);
 
@@ -209,15 +208,7 @@ static void dump_hdata_fdt(struct dt_node *root, const char *filename)
 		return;
 	}
 
-	f = fopen(filename, "wb");
-	if (!f) {
-		fprintf(stderr, "Unable to open '%s' for writing\n", filename);
-		free(fdt_blob);
-		return;
-	}
-
-	fwrite(fdt_blob, fdt_totalsize(fdt_blob), 1, f);
-	fclose(f);
+	fwrite(fdt_blob, fdt_totalsize(fdt_blob), 1, stdout);
 
 	free(fdt_blob);
 }
@@ -225,23 +216,15 @@ static void dump_hdata_fdt(struct dt_node *root, const char *filename)
 int main(int argc, char *argv[])
 {
 	int fd, r, i = 0, opt_count = 0;
-	bool verbose = false, quiet = false, tree_only = false;
-	bool new_spira = false, blobs = false;
-	const char *fdt_filename = NULL;
+	bool verbose = false, quiet = false, new_spira = false, blobs = false;
 
 	while (argv[++i]) {
-		if (strcmp(argv[i], "-f") == 0) {
-			fdt_filename = argv[++i];
-			opt_count += 2;
-		} else if (strcmp(argv[i], "-v") == 0) {
+		if (strcmp(argv[i], "-v") == 0) {
 			verbose = true;
 			opt_count++;
 		} else if (strcmp(argv[i], "-q") == 0) {
 			quiet = true;
 			opt_count++;
-		} else if (strcmp(argv[i], "-t") == 0) {
-			tree_only = true;
-			opt_count++;
 		} else if (strcmp(argv[i], "-s") == 0) {
 			new_spira = true;
 			opt_count++;
@@ -254,15 +237,17 @@ int main(int argc, char *argv[])
 	argc -= opt_count;
 	argv += opt_count;
 	if (argc != 3) {
-		errx(1, "Usage:\n"
-			"	hdata <opts> <spira-dump> <heap-dump>\n"
-			"	hdata <opts> -s <spirah-dump> <spiras-dump>\n"
-			"Options: \n"
-			"	-v Verbose\n"
-			"	-q Quiet mode\n"
-			"	-t Print the DT nodes only, no properties\n"
-			"	-f <filename> File to write the FDT into\n"
-			"       -b Keep blobs in the output\n");
+		errx(1, "Converts HDAT dumps to DTB.\n"
+		     "\n"
+		     "Usage:\n"
+		     "	hdata <opts> <spira-dump> <heap-dump>\n"
+		     "	hdata <opts> -s <spirah-dump> <spiras-dump>\n"
+		     "Options: \n"
+		     "	-v Verbose\n"
+		     "	-q Quiet mode\n"
+		     "	-b Keep blobs in the output\n"
+		     "\n"
+		     "Pipe to 'dtc -I dtb -O dts' for human readable\n");
 	}
 
 	/* Copy in spira dump (assumes little has changed!). */
@@ -334,10 +319,7 @@ int main(int argc, char *argv[])
 		squash_blobs(dt_root);
 
 	if (!quiet)
-		dump_dt(dt_root, 0, !tree_only);
-
-	if (fdt_filename)
-		dump_hdata_fdt(dt_root, fdt_filename);
+		dump_hdata_fdt(dt_root);
 
 	dt_free(dt_root);
 	return 0;
diff --git a/hdata/test/stubs.c b/hdata/test/stubs.c
index 17f17a8351ca..bea433c2693f 100644
--- a/hdata/test/stubs.c
+++ b/hdata/test/stubs.c
@@ -38,7 +38,7 @@ void _prlog(int log_level __attribute__((unused)), const char* fmt, ...)
 
         va_start(ap, fmt);
         if (log_level < 7)
-		vprintf(fmt, ap);
+		vfprintf(stderr, fmt, ap);
         va_end(ap);
 }
 
diff --git a/opal-ci/Dockerfile-centos6 b/opal-ci/Dockerfile-centos6
index 6fa069c82110..162b32b7933e 100644
--- a/opal-ci/Dockerfile-centos6
+++ b/opal-ci/Dockerfile-centos6
@@ -1,6 +1,6 @@
 FROM centos:6
 RUN yum -y update && yum clean all
-RUN yum -y install wget curl xterm gcc git xz ccache
+RUN yum -y install wget curl xterm gcc git xz ccache dtc
 RUN wget https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.8.0/x86_64-gcc-4.8.0-nolibc_powerpc64-linux.tar.xz
 RUN mkdir /opt/cross
 RUN tar -C /opt/cross -xf x86_64-gcc-4.8.0-nolibc_powerpc64-linux.tar.xz
diff --git a/opal-ci/Dockerfile-centos7 b/opal-ci/Dockerfile-centos7
index 1f4d82964ea7..1708a744d65f 100644
--- a/opal-ci/Dockerfile-centos7
+++ b/opal-ci/Dockerfile-centos7
@@ -1,6 +1,6 @@
 FROM centos:7
 RUN yum -y update && yum clean all
-RUN yum -y install wget curl xterm gcc git xz make diffutils findutils expect valgrind valgrind-devel ccache
+RUN yum -y install wget curl xterm gcc git xz make diffutils findutils expect valgrind valgrind-devel ccache dtc
 RUN wget https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.8.0/x86_64-gcc-4.8.0-nolibc_powerpc64-linux.tar.xz
 RUN mkdir /opt/cross
 RUN tar -C /opt/cross -xf x86_64-gcc-4.8.0-nolibc_powerpc64-linux.tar.xz
@@ -8,6 +8,9 @@ RUN curl -O http://public.dhe.ibm.com/software/server/powerfuncsim/p8/packages/v
 RUN yum install -y systemsim-p8-1.0-2.el7.x86_64.rpm
 RUN curl -O http://public.dhe.ibm.com/software/server/powerfuncsim/p9/packages/v1.0-0/systemsim-p9-1.0-0.el7.x86_64.rpm 
 RUN yum install -y systemsim-p9-1.0-0.el7.x86_64.rpm
+RUN yum install -y flex bison
+RUN curl -L https://github.com/dgibson/dtc/archive/v1.4.2.tar.gz|tar xfz -
+RUN (cd dtc-1.4.2; make PREFIX=/usr/local install)
 COPY . /build/
 WORKDIR /build
 ENTRYPOINT ./opal-ci/build-centos7.sh
diff --git a/opal-ci/Dockerfile-fedora-rawhide b/opal-ci/Dockerfile-fedora-rawhide
index 2fe4e09a20b4..443e4091b702 100644
--- a/opal-ci/Dockerfile-fedora-rawhide
+++ b/opal-ci/Dockerfile-fedora-rawhide
@@ -1,5 +1,5 @@
 FROM fedora:rawhide
-RUN dnf -y install wget curl xterm gcc git xz make diffutils findutils expect valgrind valgrind-devel ccache
+RUN dnf -y install wget curl xterm gcc git xz make diffutils findutils expect valgrind valgrind-devel ccache dtc
 RUN dnf -y install gcc-powerpc64-linux-gnu 
 RUN dnf -y install http://public.dhe.ibm.com/software/server/powerfuncsim/p9/packages/v1.0-0/systemsim-p9-1.0-0.f22.x86_64.rpm
 COPY . /build/
diff --git a/opal-ci/Dockerfile-fedora24 b/opal-ci/Dockerfile-fedora24
index 8110a2d49bc5..a1206402d0be 100644
--- a/opal-ci/Dockerfile-fedora24
+++ b/opal-ci/Dockerfile-fedora24
@@ -1,5 +1,5 @@
 FROM fedora:24
-RUN dnf -y install wget curl xterm gcc git xz make diffutils findutils expect valgrind valgrind-devel ccache
+RUN dnf -y install wget curl xterm gcc git xz make diffutils findutils expect valgrind valgrind-devel ccache dtc
 RUN dnf -y install gcc-powerpc64-linux-gnu 
 RUN dnf -y install http://public.dhe.ibm.com/software/server/powerfuncsim/p9/packages/v1.0-0/systemsim-p9-1.0-0.f22.x86_64.rpm 
 COPY . /build/
diff --git a/opal-ci/Dockerfile-fedora25 b/opal-ci/Dockerfile-fedora25
index eabb6e7ce228..dcc683f7e03a 100644
--- a/opal-ci/Dockerfile-fedora25
+++ b/opal-ci/Dockerfile-fedora25
@@ -1,5 +1,5 @@
 FROM fedora:25
-RUN dnf -y install wget curl xterm gcc git xz make diffutils findutils expect valgrind valgrind-devel ccache
+RUN dnf -y install wget curl xterm gcc git xz make diffutils findutils expect valgrind valgrind-devel ccache dtc
 RUN dnf -y install gcc-powerpc64-linux-gnu 
 RUN dnf -y install http://public.dhe.ibm.com/software/server/powerfuncsim/p9/packages/v1.0-0/systemsim-p9-1.0-0.f22.x86_64.rpm
 COPY . /build/
diff --git a/opal-ci/Dockerfile-ubuntu-12.04 b/opal-ci/Dockerfile-ubuntu-12.04
index ee64e920e3c4..f38c482090fe 100644
--- a/opal-ci/Dockerfile-ubuntu-12.04
+++ b/opal-ci/Dockerfile-ubuntu-12.04
@@ -3,7 +3,7 @@ RUN sudo apt-get update -qq
 RUN sudo apt-get install -y software-properties-common
 RUN sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
 RUN sudo apt-get update -qq
-RUN sudo apt-get install -y gcc-4.8 libstdc++6 valgrind expect xterm ccache expect
+RUN sudo apt-get install -y gcc-4.8 libstdc++6 valgrind expect xterm ccache expect device-tree-compiler
 RUN sudo apt-get install -y gcc-arm-linux-gnueabi gcc-powerpc64le-linux-gnu gcc
 RUN sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
 RUN sudo apt-get install -y wget curl
diff --git a/opal-ci/Dockerfile-ubuntu-16.04 b/opal-ci/Dockerfile-ubuntu-16.04
index 03cd5c57823b..11bd1cebff40 100644
--- a/opal-ci/Dockerfile-ubuntu-16.04
+++ b/opal-ci/Dockerfile-ubuntu-16.04
@@ -1,7 +1,7 @@
 FROM ubuntu:16.04
 RUN apt-get update -qq
 RUN apt-get install -y gcc-powerpc64le-linux-gnu gcc ccache expect
-RUN apt-get install -y wget curl xterm
+RUN apt-get install -y wget curl xterm device-tree-compiler
 RUN apt-get install -y gcc-arm-linux-gnueabi
 RUN curl -O ftp://public.dhe.ibm.com/software/server/powerfuncsim/p8/packages/v1.0-2/systemsim-p8_1.0-2_amd64.deb
 RUN dpkg -i systemsim-p8_1.0-2_amd64.deb
diff --git a/opal-ci/Dockerfile-ubuntu-latest b/opal-ci/Dockerfile-ubuntu-latest
index dc9a57f8eea7..2b9b0382f84e 100644
--- a/opal-ci/Dockerfile-ubuntu-latest
+++ b/opal-ci/Dockerfile-ubuntu-latest
@@ -1,7 +1,7 @@
 FROM ubuntu:latest
 RUN apt-get update -qq
 RUN apt-get install -y gcc-powerpc64le-linux-gnu gcc ccache expect
-RUN apt-get install -y wget xterm curl
+RUN apt-get install -y wget xterm curl device-tree-compiler
 RUN apt-get install -y gcc-arm-linux-gnueabi
 RUN curl -O ftp://public.dhe.ibm.com/software/server/powerfuncsim/p8/packages/v1.0-2/systemsim-p8_1.0-2_amd64.deb
 RUN dpkg -i systemsim-p8_1.0-2_amd64.deb
diff --git a/test/dt_common.c b/test/dt_common.c
index 762208124080..2da1d72d5e9f 100644
--- a/test/dt_common.c
+++ b/test/dt_common.c
@@ -47,7 +47,9 @@ static void dump_val(unsigned indent, const void *prop, size_t size)
 	}
 }
 
-static void dump_dt(const struct dt_node *root, unsigned indent, bool show_props)
+void dump_dt(const struct dt_node *root, unsigned indent, bool show_props);
+
+void dump_dt(const struct dt_node *root, unsigned indent, bool show_props)
 {
 	const struct dt_node *i;
 	const struct dt_property *p;
-- 
2.9.3



More information about the Skiboot mailing list