mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
Merge branch 'oom' of git://github.com/capveg/OpenNetworkLinux into oom
Conflicts: packages/base/any/oom-shim/APKG.yml packages/base/any/oom_shim/builds/Makefile
This commit is contained in:
6
Makefile
6
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
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
#
|
||||
|
||||
@@ -154,6 +154,15 @@ 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 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))
|
||||
sys.exit(execute(c))
|
||||
|
||||
2
packages/base/amd64/oom-shim/PKG.yml
Normal file
2
packages/base/amd64/oom-shim/PKG.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
!include $ONL/packages/base/any/oom-shim/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu
|
||||
|
||||
3
packages/base/amd64/oom-shim/builds/Makefile
Normal file
3
packages/base/amd64/oom-shim/builds/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
include $(ONL)/packages/base/any/oom-shim/builds/Makefile
|
||||
|
||||
10
packages/base/amd64/oom-shim/builds/oom_shim.mk
Normal file
10
packages/base/amd64/oom-shim/builds/oom_shim.mk
Normal file
@@ -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))))
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
!include $ONL/packages/base/any/oom_shim/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
include $(ONL)/packages/base/any/oom_shim/builds/Makefile
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
prerequisites:
|
||||
packages: [ "onlp:$ARCH" ]
|
||||
|
||||
common:
|
||||
arch: $ARCH
|
||||
version: 1.0.0
|
||||
|
||||
@@ -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 <id> 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 <id> 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 <id> 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 <id> 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 <id> has failed.",
|
||||
"The given fan has failed.",
|
||||
"Fan %d has failed.", fid);
|
||||
}
|
||||
flag[i] = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Log any presences or failure transitions.
|
||||
*/
|
||||
|
||||
@@ -17,13 +17,17 @@ common:
|
||||
|
||||
|
||||
packages:
|
||||
- name: oom_shim
|
||||
- name: oom-shim
|
||||
version: 1.0.0
|
||||
summary: Open Optical Module Wrapper library around ONLP
|
||||
provides: [ oom_shim ]
|
||||
|
||||
files:
|
||||
<<<<<<< HEAD:packages/base/any/oom_shim/APKG.yml
|
||||
builds/$BUILD_DIR/${TOOLCHAIN}/liboom_south.so : $libdir/
|
||||
=======
|
||||
builds/$BUILD_DIR/${TOOLCHAIN}/bin/liboom-south.so : $libdir/
|
||||
>>>>>>> 33bb8c0690eb1fdc693283ffa35f06bcf2f00303:packages/base/any/oom-shim/APKG.yml
|
||||
|
||||
changelog: Initial code for 2016 OCP Demo
|
||||
|
||||
53
packages/base/any/oom-shim/builds/Makefile
Normal file
53
packages/base/any/oom-shim/builds/Makefile
Normal file
@@ -0,0 +1,53 @@
|
||||
# -*- Makefile -*-
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
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
|
||||
4
packages/base/any/oom-shim/src/Makefile
Normal file
4
packages/base/any/oom-shim/src/Makefile
Normal file
@@ -0,0 +1,4 @@
|
||||
include $(ONL)/make/config.mk
|
||||
MODULE := oom_shim
|
||||
AUTOMODULE := oom_shim
|
||||
include $(BUILDER)/definemodule.mk
|
||||
28
packages/base/any/oom-shim/src/module/auto/make.mk
Normal file
28
packages/base/any/oom-shim/src/module/auto/make.mk
Normal file
@@ -0,0 +1,28 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2013 v=onl>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
# 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
|
||||
|
||||
86
packages/base/any/oom-shim/src/module/auto/oom_shim.yml
Normal file
86
packages/base/any/oom-shim/src/module/auto/oom_shim.yml
Normal file
@@ -0,0 +1,86 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2013 v=onl>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
# 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
|
||||
30
packages/base/any/oom-shim/src/module/make.mk
Normal file
30
packages/base/any/oom-shim/src/module/make.mk
Normal file
@@ -0,0 +1,30 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
|
||||
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
|
||||
|
||||
12
packages/base/any/oom-shim/src/oom_shim.mk
Normal file
12
packages/base/any/oom-shim/src/oom_shim.mk
Normal file
@@ -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
|
||||
|
||||
28
packages/base/any/oom-shim/src/utest/_make.mk
Normal file
28
packages/base/any/oom-shim/src/utest/_make.mk
Normal file
@@ -0,0 +1,28 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
|
||||
UMODULE := oom_shim
|
||||
UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
include $(BUILDER)/utest.mk
|
||||
131
packages/base/any/oom-shim/src/utest/main.c
Normal file
131
packages/base/any/oom-shim/src/utest/main.c
Normal file
@@ -0,0 +1,131 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlp/onlp_config.h>
|
||||
#include <onlp/oids.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <AIM/aim.h>
|
||||
#include <onlp/onlp.h>
|
||||
#include <onlplib/shlocks.h>
|
||||
|
||||
/**
|
||||
* 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 <onlp/fan.h>
|
||||
#include <onlp/thermal.h>
|
||||
#include <onlp/oids.h>
|
||||
#include <onlp/sys.h>
|
||||
|
||||
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;
|
||||
}
|
||||
Submodule packages/platforms-closed updated: 52a6f7f8d5...ca6abea540
Reference in New Issue
Block a user