Changed OOM_SHIM package to module formatted code

This commit is contained in:
Rob Sherwood
2016-02-12 09:19:29 -08:00
parent 7a43104c66
commit 33bb8c0690
19 changed files with 389 additions and 34 deletions

View File

@@ -0,0 +1,2 @@
!include $ONL/packages/base/any/oom-shim/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu

View File

@@ -0,0 +1,3 @@
include $(ONL)/make/config.amd64.mk
include $(ONL)/packages/base/any/oom-shim/builds/Makefile

View 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))))

View File

@@ -1,2 +0,0 @@
!include $ONL/packages/base/any/oom_shim/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu

View File

@@ -1,3 +0,0 @@
include $(ONL)/make/config.amd64.mk
include $(ONL)/packages/base/any/oom_shim/builds/Makefile

View File

@@ -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

View 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

View File

@@ -0,0 +1,4 @@
include $(ONL)/make/config.mk
MODULE := oom_shim
AUTOMODULE := oom_shim
include $(BUILDER)/definemodule.mk

View 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

View 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

View 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

View 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

View 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

View 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;
}

View File

@@ -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)