From 5bfe3ceaac09d0e0ae12b339e146122f583dfef1 Mon Sep 17 00:00:00 2001 From: Rob Sherwood Date: Tue, 2 Feb 2016 13:05:04 -0800 Subject: [PATCH 1/9] added `make docker-debug` target --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 07e150db..f053489a 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ # ############################################################ ifneq ($(MAKECMDGOALS),docker) +ifneq ($(MAKECMDGOALS),docker-debug) ifndef ONL $(error Please source the setup.env script at the root of the ONL tree) @@ -30,6 +31,7 @@ rpc rebuild: $(ONLPM) --rebuild-pkg-cache endif +endif .PHONY: docker @@ -43,3 +45,7 @@ docker_check: docker: docker_check @docker/tools/onlbuilder -$(VERSION) --isolate --hostname onlbuilder$(VERSION) --pull --autobuild --non-interactive + +# create an interative docker shell, for debugging builds +docker-debug: docker_check + @docker/tools/onlbuilder -$(VERSION) --isolate --hostname onlbuilder$(VERSION) --pull From b2004243e1184fbc9744756cc831d8d330fe4a91 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 2 Feb 2016 21:52:08 +0000 Subject: [PATCH 2/9] Add onlp as a proper prerequisite. --- packages/base/any/onlp-snmpd/APKG.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/base/any/onlp-snmpd/APKG.yml b/packages/base/any/onlp-snmpd/APKG.yml index 6e70c5f4..d931723e 100644 --- a/packages/base/any/onlp-snmpd/APKG.yml +++ b/packages/base/any/onlp-snmpd/APKG.yml @@ -1,3 +1,6 @@ +prerequisites: + packages: [ "onlp:$ARCH" ] + common: arch: $ARCH version: 1.0.0 From 1e21a2350bff784e1cc58dad1caaf340524d6512 Mon Sep 17 00:00:00 2001 From: Steven Noble Date: Tue, 2 Feb 2016 14:56:22 -0800 Subject: [PATCH 3/9] Updates to docker_shell to setup binfmt --- docker/tools/docker_shell | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docker/tools/docker_shell b/docker/tools/docker_shell index 9c49883e..7ad78047 100755 --- a/docker/tools/docker_shell +++ b/docker/tools/docker_shell @@ -154,6 +154,17 @@ for u in ops.addusers: if ops.start_cacher: execute("/etc/init.d/apt-cacher-ng start", "The apt-cacher-ng service could not be started.") +logger.debug("checking if qemu-ppc exists") + +if os.path.isfile("/proc/sys/fs/binfmt_misc/qemu-ppc"): + logger.debug("qemu-ppc already exists") +else: + if os.path.ismount("/proc/sys/fs/binfmt_misc"): + execute("sudo /etc/init.d/binfmt-support start", "The binfmt-support service could not be started.") + else: + execute("sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc", "The binfmt_misc system could not be mounted.") + execute("sudo /etc/init.d/binfmt-support start", "The binfmt-support service could not be started.") + # Fixme: change this to os.execvp() c = "/usr/bin/sudo -E -u %s %s" % (g_user.name, " ".join(ops.command)) sys.exit(execute(c)) From a9371065859c1a44addfb1c8363940bba6d84f32 Mon Sep 17 00:00:00 2001 From: Steven Noble Date: Tue, 2 Feb 2016 23:23:36 +0000 Subject: [PATCH 4/9] updated per capveg suggestions --- docker/tools/docker_shell | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docker/tools/docker_shell b/docker/tools/docker_shell index 7ad78047..6376b7b1 100755 --- a/docker/tools/docker_shell +++ b/docker/tools/docker_shell @@ -159,11 +159,9 @@ logger.debug("checking if qemu-ppc exists") if os.path.isfile("/proc/sys/fs/binfmt_misc/qemu-ppc"): logger.debug("qemu-ppc already exists") else: - if os.path.ismount("/proc/sys/fs/binfmt_misc"): - execute("sudo /etc/init.d/binfmt-support start", "The binfmt-support service could not be started.") - else: - execute("sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc", "The binfmt_misc system could not be mounted.") - execute("sudo /etc/init.d/binfmt-support start", "The binfmt-support service could not be started.") + if not os.path.ismount("/proc/sys/fs/binfmt_misc"): + execute("sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc", "The binfmt_misc system could not be mounted.") + execute("sudo /etc/init.d/binfmt-support start", "The binfmt-support service could not be started.") # Fixme: change this to os.execvp() c = "/usr/bin/sudo -E -u %s %s" % (g_user.name, " ".join(ops.command)) From 8690f135d9d3ffb7c66d928922e9b361793fb2be Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 3 Feb 2016 17:22:29 +0000 Subject: [PATCH 5/9] QSFP Driver Fix. --- ...form-accton-as5812_54t-device-drivers.patch | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/packages/base/any/kernels/3.2.65-1+deb7u2/patches/platform-accton-as5812_54t-device-drivers.patch b/packages/base/any/kernels/3.2.65-1+deb7u2/patches/platform-accton-as5812_54t-device-drivers.patch index 5281309c..dfe66f46 100644 --- a/packages/base/any/kernels/3.2.65-1+deb7u2/patches/platform-accton-as5812_54t-device-drivers.patch +++ b/packages/base/any/kernels/3.2.65-1+deb7u2/patches/platform-accton-as5812_54t-device-drivers.patch @@ -1533,7 +1533,7 @@ new file mode 100644 index 0000000..0985c80 --- /dev/null +++ b/drivers/misc/eeprom/accton_as5812_54t_sfp.c -@@ -0,0 +1,332 @@ +@@ -0,0 +1,318 @@ +/* + * An hwmon driver for accton as5812_54t sfp + * @@ -1768,20 +1768,6 @@ index 0000000..0985c80 + return result; +} + -+static int convert_cpld_present_value_in_port_order(int value) -+{ -+ int ret = 0; -+ -+ ret |= (value & BIT_INDEX(0)) << 5; -+ ret |= (value & BIT_INDEX(1)) << 1; -+ ret |= (value & BIT_INDEX(2)) >> 1; -+ ret |= (value & BIT_INDEX(3)) << 1; -+ ret |= (value & BIT_INDEX(4)) >> 4; -+ ret |= (value & BIT_INDEX(5)) >> 2; -+ -+ return ret; -+} -+ +static struct as5812_54t_sfp_data *as5812_54t_sfp_update_device(struct device *dev, int update_eeprom) +{ + struct i2c_client *client = to_i2c_client(dev); @@ -1812,7 +1798,7 @@ index 0000000..0985c80 + dev_dbg(&client->dev, "cpld(0x60) reg(0x22) err %d\n", status); + } + else { -+ data->status = convert_cpld_present_value_in_port_order(status); /* (u32)status */ ++ data->status = status & 0x3F; /* (u32)status */ + } + + if (update_eeprom) { From aabf40fbf2fda81ac58f0a86705a35a6b1334fd0 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 3 Feb 2016 09:41:44 -0800 Subject: [PATCH 6/9] LAtest --- packages/platforms-closed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms-closed b/packages/platforms-closed index 52a6f7f8..ca6abea5 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit 52a6f7f8d5357a3ae2e4550b4ffff7cd5a38f3b8 +Subproject commit ca6abea54088ad74ad2fe044a39522224ac90a5d From e0873255eca036aebc8841a3528bf3e9657675d2 Mon Sep 17 00:00:00 2001 From: Steven Noble Date: Thu, 4 Feb 2016 12:41:15 -0800 Subject: [PATCH 7/9] report initial fan/psu failed state to syslog pull 21 from onlp --- .../src/onlp/module/src/platform_manager.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/packages/base/any/onlp/src/onlp/module/src/platform_manager.c b/packages/base/any/onlp/src/onlp/module/src/platform_manager.c index f724e9d6..a2a884b2 100644 --- a/packages/base/any/onlp/src/onlp/module/src/platform_manager.c +++ b/packages/base/any/onlp/src/onlp/module/src/platform_manager.c @@ -273,6 +273,7 @@ platform_psus_notify__(void) static onlp_oid_t psu_oid_table[ONLP_OID_TABLE_SIZE] = {0}; static onlp_psu_info_t psu_info_table[ONLP_OID_TABLE_SIZE]; int i = 0; + static int flag[ONLP_OID_TABLE_SIZE] = {0}; if(psu_oid_table[0] == 0) { /* We haven't retreived the system PSU oids yet. */ @@ -302,6 +303,26 @@ platform_psus_notify__(void) continue; } + /* report initial failed state */ + if ( !flag[i] ) { + if ( !(pi.status & 0x1) ) { + AIM_SYSLOG_WARN("PSU is not present.", + "The given PSU is not present.", + "PSU %d is not present.", pid); + } + if ( pi.status & ONLP_PSU_STATUS_FAILED ) { + AIM_SYSLOG_CRIT("PSU has failed.", + "The given PSU has failed.", + "PSU %d has failed.", pid); + } + if ((pi.status & 0x01) && !(pi.status & ONLP_PSU_STATUS_FAILED) && (pi.status & ONLP_PSU_STATUS_UNPLUGGED)) { + AIM_SYSLOG_WARN("PSU power cord not plugged.", + "The given PSU does not have power cord plugged.", + "PSU %d power cord not plugged.", pid); + } + flag[i] = 1; + } + /* * Log any presences or failure transitions. */ @@ -363,6 +384,7 @@ platform_fans_notify__(void) static onlp_oid_t fan_oid_table[ONLP_OID_TABLE_SIZE] = {0}; static onlp_fan_info_t fan_info_table[ONLP_OID_TABLE_SIZE]; int i = 0; + static int flag[ONLP_OID_TABLE_SIZE] = {0}; if(fan_oid_table[0] == 0) { /* We haven't retreived the system FAN oids yet. */ @@ -392,6 +414,21 @@ platform_fans_notify__(void) continue; } + /* report initial failed state */ + if ( !flag[i] ) { + if ( !(fi.status & 0x1) ) { + AIM_SYSLOG_WARN("Fan is not present.", + "The given Fan is not present.", + "Fan %d is not present.", fid); + } + if ( fi.status & ONLP_FAN_STATUS_FAILED ) { + AIM_SYSLOG_CRIT("Fan has failed.", + "The given fan has failed.", + "Fan %d has failed.", fid); + } + flag[i] = 1; + } + /* * Log any presences or failure transitions. */ From 90c8fddb755903cea079cd971b87b4a673ecdaa6 Mon Sep 17 00:00:00 2001 From: Steven Noble Date: Tue, 9 Feb 2016 17:15:07 -0800 Subject: [PATCH 8/9] Update Dockerfile fixing whitespace issue line 131 --- docker/images/builder8/1.0/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker/images/builder8/1.0/Dockerfile b/docker/images/builder8/1.0/Dockerfile index b0772495..d1486635 100644 --- a/docker/images/builder8/1.0/Dockerfile +++ b/docker/images/builder8/1.0/Dockerfile @@ -127,8 +127,7 @@ RUN echo 'APT::Get::AllowUnauthenticated "true";\nAPT::Get::Assume-Yes "true";' dpkg -i texinfo_4.13a.dfsg.1-10_amd64.deb && \ wget "http://ftp.us.debian.org/debian/pool/main/e/emdebian-crush/xapt_2.2.19_all.deb" && \ dpkg -i xapt_2.2.19_all.deb && \ - - xapt -a powerpc libedit-dev ncurses-dev libsensors4-dev libwrap0-dev libssl-dev libsnmp-dev + xapt -a powerpc libedit-dev ncurses-dev libsensors4-dev libwrap0-dev libssl-dev libsnmp-dev # update-alternatives --install /usr/bin/powerpc-linux-gnu-gcc powerpc-linux-gnu-gcc 10 && # From 33bb8c0690eb1fdc693283ffa35f06bcf2f00303 Mon Sep 17 00:00:00 2001 From: Rob Sherwood Date: Fri, 12 Feb 2016 09:19:29 -0800 Subject: [PATCH 9/9] Changed OOM_SHIM package to module formatted code --- .../amd64/{oom_shim => oom-shim}/Makefile | 0 packages/base/amd64/oom-shim/PKG.yml | 2 + packages/base/amd64/oom-shim/builds/Makefile | 3 + .../base/amd64/oom-shim/builds/oom_shim.mk | 10 ++ packages/base/amd64/oom_shim/PKG.yml | 2 - packages/base/amd64/oom_shim/builds/Makefile | 3 - .../base/any/{oom_shim => oom-shim}/APKG.yml | 4 +- packages/base/any/oom-shim/builds/Makefile | 53 +++++++ packages/base/any/oom-shim/src/Makefile | 4 + .../base/any/oom-shim/src/module/auto/make.mk | 28 ++++ .../any/oom-shim/src/module/auto/oom_shim.yml | 86 ++++++++++++ .../src/module/inc/oom-shim/oom-shim.h | 0 .../src/module/inc/oom_shim/oom-shim.h | 0 packages/base/any/oom-shim/src/module/make.mk | 30 ++++ .../src/module}/src/oom_shim.c | 0 packages/base/any/oom-shim/src/oom_shim.mk | 12 ++ packages/base/any/oom-shim/src/utest/_make.mk | 28 ++++ packages/base/any/oom-shim/src/utest/main.c | 131 ++++++++++++++++++ packages/base/any/oom_shim/builds/Makefile | 27 ---- 19 files changed, 389 insertions(+), 34 deletions(-) rename packages/base/amd64/{oom_shim => oom-shim}/Makefile (100%) create mode 100644 packages/base/amd64/oom-shim/PKG.yml create mode 100644 packages/base/amd64/oom-shim/builds/Makefile create mode 100644 packages/base/amd64/oom-shim/builds/oom_shim.mk delete mode 100644 packages/base/amd64/oom_shim/PKG.yml delete mode 100644 packages/base/amd64/oom_shim/builds/Makefile rename packages/base/any/{oom_shim => oom-shim}/APKG.yml (85%) create mode 100644 packages/base/any/oom-shim/builds/Makefile create mode 100644 packages/base/any/oom-shim/src/Makefile create mode 100644 packages/base/any/oom-shim/src/module/auto/make.mk create mode 100644 packages/base/any/oom-shim/src/module/auto/oom_shim.yml create mode 100644 packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h create mode 100644 packages/base/any/oom-shim/src/module/inc/oom_shim/oom-shim.h create mode 100644 packages/base/any/oom-shim/src/module/make.mk rename packages/base/any/{oom_shim => oom-shim/src/module}/src/oom_shim.c (100%) create mode 100644 packages/base/any/oom-shim/src/oom_shim.mk create mode 100644 packages/base/any/oom-shim/src/utest/_make.mk create mode 100644 packages/base/any/oom-shim/src/utest/main.c delete mode 100644 packages/base/any/oom_shim/builds/Makefile diff --git a/packages/base/amd64/oom_shim/Makefile b/packages/base/amd64/oom-shim/Makefile similarity index 100% rename from packages/base/amd64/oom_shim/Makefile rename to packages/base/amd64/oom-shim/Makefile diff --git a/packages/base/amd64/oom-shim/PKG.yml b/packages/base/amd64/oom-shim/PKG.yml new file mode 100644 index 00000000..7f4f460d --- /dev/null +++ b/packages/base/amd64/oom-shim/PKG.yml @@ -0,0 +1,2 @@ +!include $ONL/packages/base/any/oom-shim/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu + diff --git a/packages/base/amd64/oom-shim/builds/Makefile b/packages/base/amd64/oom-shim/builds/Makefile new file mode 100644 index 00000000..66500cec --- /dev/null +++ b/packages/base/amd64/oom-shim/builds/Makefile @@ -0,0 +1,3 @@ +include $(ONL)/make/config.amd64.mk +include $(ONL)/packages/base/any/oom-shim/builds/Makefile + diff --git a/packages/base/amd64/oom-shim/builds/oom_shim.mk b/packages/base/amd64/oom-shim/builds/oom_shim.mk new file mode 100644 index 00000000..88c00283 --- /dev/null +++ b/packages/base/amd64/oom-shim/builds/oom_shim.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the oom_shim module. +# +# Autogenerated 2016-02-12 17:14:48.789289 +# +############################################################################### +oom_shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/base/amd64/oom_shim/PKG.yml b/packages/base/amd64/oom_shim/PKG.yml deleted file mode 100644 index d8f9b23f..00000000 --- a/packages/base/amd64/oom_shim/PKG.yml +++ /dev/null @@ -1,2 +0,0 @@ -!include $ONL/packages/base/any/oom_shim/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu - diff --git a/packages/base/amd64/oom_shim/builds/Makefile b/packages/base/amd64/oom_shim/builds/Makefile deleted file mode 100644 index a6c9d258..00000000 --- a/packages/base/amd64/oom_shim/builds/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -include $(ONL)/make/config.amd64.mk -include $(ONL)/packages/base/any/oom_shim/builds/Makefile - diff --git a/packages/base/any/oom_shim/APKG.yml b/packages/base/any/oom-shim/APKG.yml similarity index 85% rename from packages/base/any/oom_shim/APKG.yml rename to packages/base/any/oom-shim/APKG.yml index e8490b9b..6a54841f 100644 --- a/packages/base/any/oom_shim/APKG.yml +++ b/packages/base/any/oom-shim/APKG.yml @@ -17,13 +17,13 @@ common: packages: - - name: oom_shim + - name: oom-shim version: 1.0.0 summary: Open Optical Module Wrapper library around ONLP provides: [ oom_shim ] files: - builds/$BUILD_DIR/${TOOLCHAIN}/liboom_shim.so : $libdir/ + builds/$BUILD_DIR/${TOOLCHAIN}/bin/liboom-south.so : $libdir/ changelog: Initial code for 2016 OCP Demo diff --git a/packages/base/any/oom-shim/builds/Makefile b/packages/base/any/oom-shim/builds/Makefile new file mode 100644 index 00000000..484d66aa --- /dev/null +++ b/packages/base/any/oom-shim/builds/Makefile @@ -0,0 +1,53 @@ +# -*- Makefile -*- +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/any.mk + +MODULE := oom_shim +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM onlplib onlp oom_shim cjson cjson_util sff IOF timer_wheel OS + + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := liboom-south.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk + +.DEFAULT_GOAL := sharedlibs + +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_CTOR_DTOR=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DONLP_CONFIG_API_LOCK_GLOBAL_SHARED=1 +GLOBAL_CFLAGS += -DONLP_CONFIG_INCLUDE_SHLOCK_GLOBAL_INIT=1 + +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread $(LIBONLP_PLATFORM) $(LIBONLP_PLATFORM_DEFAULTS) + +include $(BUILDER)/targets.mk + +.PHONY: deb +deb: + $(MAKE) -C deb diff --git a/packages/base/any/oom-shim/src/Makefile b/packages/base/any/oom-shim/src/Makefile new file mode 100644 index 00000000..ee296946 --- /dev/null +++ b/packages/base/any/oom-shim/src/Makefile @@ -0,0 +1,4 @@ +include $(ONL)/make/config.mk +MODULE := oom_shim +AUTOMODULE := oom_shim +include $(BUILDER)/definemodule.mk diff --git a/packages/base/any/oom-shim/src/module/auto/make.mk b/packages/base/any/oom-shim/src/module/auto/make.mk new file mode 100644 index 00000000..9dac4629 --- /dev/null +++ b/packages/base/any/oom-shim/src/module/auto/make.mk @@ -0,0 +1,28 @@ +############################################################ +# +# +# Copyright 2013, 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# faultd Autogeneration +# +############################################################ +oom_shim_AUTO_DEFS := module/auto/oom_shim.yml +oom_shim_AUTO_DIRS := module/inc/oom_shim module/src +include $(BUILDER)/auto.mk + diff --git a/packages/base/any/oom-shim/src/module/auto/oom_shim.yml b/packages/base/any/oom-shim/src/module/auto/oom_shim.yml new file mode 100644 index 00000000..32557d9e --- /dev/null +++ b/packages/base/any/oom-shim/src/module/auto/oom_shim.yml @@ -0,0 +1,86 @@ +############################################################ +# +# +# Copyright 2013, 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# faultd Autogeneration Definitions. +# +############################################################ + +cdefs: &cdefs +- OOM_SHIM_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- OOM_SHIM_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- OOM_SHIM_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- OOM_SHIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- OOM_SHIM_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- OOM_SHIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: OOM_SHIM_CONFIG_PORTING_STDLIB +- OOM_SHIM_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- OOM_SHIM_CONFIG_PIPE_NAME_DEFAULT: + doc: "Default named pipe." + default: "\"/var/run/faultd.pipe\"" +- OOM_SHIM_CONFIG_BINARY_SIZE: + doc: "Maximum binary name size." + default: 255 +- OOM_SHIM_CONFIG_BACKTRACE_SIZE_MAX: + doc: "Maximum backtrace size." + default: 32 +- OOM_SHIM_CONFIG_SERVICE_PIPES_MAX: + doc: "Maximum number of simulatanous service pipes." + default: 8 +- OOM_SHIM_CONFIG_BACKTRACE_SYMBOLS_SIZE: + doc: "Maximum backtrace symbols size" + default: 4096 +- OOM_SHIM_CONFIG_INCLUDE_MAIN: + doc: "Include faultd_main() for standard faultd daemon build." + default: 0 +- OOM_SHIM_CONFIG_INCLUDE_AIM_MAIN: + doc: "Include aim_main() as faultd_main()." + default: OOM_SHIM_CONFIG_INCLUDE_MAIN +- OOM_SHIM_CONFIG_MAIN_PIPENAME: + doc: "Default pipename used by faultd_main() if included." + default: "\"/var/run/faultd.fifo\"" + + +definitions: + cdefs: + OOM_SHIM_CONFIG_HEADER: + defs: *cdefs + basename: faultd_config + + portingmacro: + OOM_SHIM: + macros: + - memset + - memcpy + - strncpy + - strlen diff --git a/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h new file mode 100644 index 00000000..e69de29b diff --git a/packages/base/any/oom-shim/src/module/inc/oom_shim/oom-shim.h b/packages/base/any/oom-shim/src/module/inc/oom_shim/oom-shim.h new file mode 100644 index 00000000..e69de29b diff --git a/packages/base/any/oom-shim/src/module/make.mk b/packages/base/any/oom-shim/src/module/make.mk new file mode 100644 index 00000000..b6ec73a3 --- /dev/null +++ b/packages/base/any/oom-shim/src/module/make.mk @@ -0,0 +1,30 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ + +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +oom_shim_INCLUDES := -I $(THIS_DIR)inc +oom_shim_INTERNAL_INCLUDES := -I $(THIS_DIR)src +oom_shim_DEPENDMODULE_ENTRIES := init:oom_shim ucli:oom_shim + diff --git a/packages/base/any/oom_shim/src/oom_shim.c b/packages/base/any/oom-shim/src/module/src/oom_shim.c similarity index 100% rename from packages/base/any/oom_shim/src/oom_shim.c rename to packages/base/any/oom-shim/src/module/src/oom_shim.c diff --git a/packages/base/any/oom-shim/src/oom_shim.mk b/packages/base/any/oom-shim/src/oom_shim.mk new file mode 100644 index 00000000..dde86cf9 --- /dev/null +++ b/packages/base/any/oom-shim/src/oom_shim.mk @@ -0,0 +1,12 @@ + +############################################################################### +# +# Inclusive Makefile for the oom-shim module. +# +# Autogenerated 2016-02-12 16:50:50.721882 +# +############################################################################### +oom-shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +include $(oom-shim_BASEDIR)/module/make.mk +include $(oom-shim_BASEDIR)/utest/_make.mk + diff --git a/packages/base/any/oom-shim/src/utest/_make.mk b/packages/base/any/oom-shim/src/utest/_make.mk new file mode 100644 index 00000000..43139d4c --- /dev/null +++ b/packages/base/any/oom-shim/src/utest/_make.mk @@ -0,0 +1,28 @@ +############################################################ +# +# +# Copyright 2014, 2015 Big Switch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ + +UMODULE := oom_shim +UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/utest.mk diff --git a/packages/base/any/oom-shim/src/utest/main.c b/packages/base/any/oom-shim/src/utest/main.c new file mode 100644 index 00000000..e7e9e030 --- /dev/null +++ b/packages/base/any/oom-shim/src/utest/main.c @@ -0,0 +1,131 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +/** + * Base functionality unit tests. + */ +#define __TRY(_prefix, _expr, _suffix) \ + do { \ + int _rv; \ + fprintf(stderr, "%s%s...%s", _prefix, #_expr, _suffix); \ + fflush(stderr); \ + _rv = _expr ; \ + fprintf(stderr, "%s%s...%d\n", _prefix, #_expr, _rv); \ + fflush(stderr); \ + if(_rv < 0) { \ + AIM_DIE("%s%s: failed: %d", #_expr, _rv); \ + } \ + } while(0) + +#define __TRYNR(_prefix, _expr, _suffix) \ + do { \ + fprintf(stderr, "%s%s...%s", _prefix, #_expr, _suffix); \ + fflush(stderr); \ + _expr ; \ + fprintf(stderr, "%s%s...Done\n", _prefix, #_expr); \ + fflush(stderr); \ + } while(0) + +#define TRY(_expr) __TRY(" ", _expr, "\r") +#define TRYNR(_expr) ___TRYNR(" ", _expr, "\r") +#define TEST(_expr) __TRYNR("", _expr, "\n"); + +/** + * Test Shared Locks + */ +void +shlock_test(void) +{ + onlp_shlock_t* lock = NULL; + + TRY(onlp_shlock_create(0xEEEF, &lock, "utest-lock:%d", 1)); + TRY(onlp_shlock_take(lock)); + TRY(onlp_shlock_give(lock)); + TRY(onlp_shlock_take(lock)); + TRY(onlp_shlock_give(lock)); + TRY(onlp_shlock_global_take()); + TRY(onlp_shlock_global_give()); + TRY(onlp_shlock_global_take()); + TRY(onlp_shlock_global_give()); + if(strcmp("utest-lock:1", onlp_shlock_name(lock))) { + AIM_DIE("lock name does not match (%s)", onlp_shlock_name(lock)); + } +} + +/** + * Test ONIE parsing + */ +void +onie_test(void) +{ + /* TODO */ +} + +int +iter__(onlp_oid_t oid, void* cookie) +{ + onlp_oid_hdr_t hdr; + onlp_oid_hdr_get(oid, &hdr); + printf("OID: 0x%x, D='%s'\n", oid, hdr.description); + return 0; +} + +#include +#include +#include +#include + +int +aim_main(int argc, char* argv[]) +{ + // TEST(shlock_test()); + + /* Example Platform Dump */ + onlp_init(); + onlp_platform_dump(&aim_pvs_stdout, ONLP_OID_DUMP_F_RECURSE); + onlp_oid_iterate(0, 0, iter__, NULL); + onlp_platform_show(&aim_pvs_stdout, ONLP_OID_SHOW_F_RECURSE|ONLP_OID_SHOW_F_EXTENDED); + + if(argv[1] && !strcmp("manage", argv[1])) { + onlp_sys_platform_manage_start(); + printf("Sleeping...\n"); + sleep(10); + printf("Stopping...\n"); + onlp_sys_platform_manage_stop(); + printf("Stopped.\n"); + } + return 0; +} diff --git a/packages/base/any/oom_shim/builds/Makefile b/packages/base/any/oom_shim/builds/Makefile deleted file mode 100644 index 8f2d99a4..00000000 --- a/packages/base/any/oom_shim/builds/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include $(ONL)/make/any.mk - -ifndef TOOLCHAIN -$(error Must define $$TOOLCHAIN to use this Makefile) -endif - -ifndef RELEASE -$(warn Assuming RELEASE is wheezy -- FIXME) -RELEASE=wheezy -endif - -PACKAGE=oom_shim - -OUTDIR=$(ONL)/packages/base/$(ARCH)/$(PACKAGE)/builds/BUILD/$(RELEASE)/$(TOOLCHAIN) - -VPATH=$(ONL)/packages/base/any/$(PACKAGE)/src - -$(OUTDIR)/liboom_shim.so: oom_shim.c - @mkdir -p $(OUTDIR) || true - @$(CC) -o $(OUTDIR)/liboom_shim.so -shared -fPIC $+ - -.PHONY: deb -deb: - $(MAKE) -C deb - -clean: - rm -rf $(OUTDIR)