diff --git a/.travis.yml b/.travis.yml index 041e1a6..919f3c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,70 +1,34 @@ -sudo: required - -group: edge - +sudo: true dist: trusty - -services: - - docker - -before_install: - - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - - sudo apt-get update - - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce - -install: - - wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3 - - wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz - - tar xf lcov_1.11.orig.tar.gz - - sudo make -C lcov-1.11/ install - - gem install coveralls-lcov - -env: - - DOCKER_MACHINE_STATUS="Running" DOCKER_MACHINE_IP="0.0.0.0" - language: erlang otp_release: - 20.2 - + - 20.3 +env: + - ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe ORACLE_SID=XE +before_install: + - eval sudo chmod +x "$(dirname `which erl`)/../erts-*/bin/epmd" + - eval "$(dirname `which erl`)/../erts-*/bin/epmd" -daemon + - export PATH=$PATH:$ORACLE_HOME/bin/ + - wget https://raw.githubusercontent.com/Vincit/travis-oracledb-xe/master/accept_the_license_agreement_for_oracledb_xe_11g_and_install.sh + - bash ./accept_the_license_agreement_for_oracledb_xe_11g_and_install.sh + - export LD_LIBRARY_PATH=$ORACLE_HOME/lib/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} +install: + - wget https://s3.amazonaws.com/rebar3/rebar3 + - chmod +x rebar3 + - wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz + - tar xf lcov_1.11.orig.tar.gz + - sudo make -C lcov-1.11/ install + - gem install coveralls-lcov before_script: - - docker version - - docker info - - kerl list installations - - lcov --directory . --zerocounters - + - kerl list installations + - lcov --directory . --zerocounters script: - - docker pull konnexionsgmbh/db_11_2_xe - - docker images - - docker create --shm-size 1G --name oranif_db -p 1521:1521/tcp -e ORACLE_PWD=oracle konnexionsgmbh/db_11_2_xe - - docker start oranif_db - - wget -q -P /tmp https://github.com/K2InformaticsGmbH/oranif/wiki/travis/oracle-instantclient19.3-basic_19.3.0.0.0-2_amd64.deb - - wget -q -P /tmp https://github.com/K2InformaticsGmbH/oranif/wiki/travis/oracle-instantclient19.3-sqlplus_19.3.0.0.0-2_amd64.deb - - sudo apt install /tmp/oracle-instantclient19.3-basic_19.3.0.0.0-2_amd64.deb - - sudo apt install /tmp/oracle-instantclient19.3-sqlplus_19.3.0.0.0-2_amd64.deb - - export LD_LIBRARY_PATH=/usr/lib/oracle/19.3/client64/lib/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} - - echo $LD_LIBRARY_PATH - - ERL_INTERFACE_DIR="$(ls -d ~/otp/$TRAVIS_OTP_RELEASE/lib/erl_interface*/)" - - OTP_ERTS_DIR="$(ls -d ~/otp/$TRAVIS_OTP_RELEASE/erts*/)" - - export ERL_INTERFACE_DIR="${ERL_INTERFACE_DIR:0:$((${#ERL_INTERFACE_DIR} - 1))}" - - export OTP_ERTS_DIR="${OTP_ERTS_DIR:0:$((${#OTP_ERTS_DIR} - 1))}" - - ./rebar3 version - - LINKODPI=true ./rebar3 as test compile - - export LD_LIBRARY_PATH=./priv/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} - - export LD_LIBRARY_PATH=./c_src/odpi/lib/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} - - while [ "`docker inspect -f {{.State.Health.Status}} oranif_db`" != "healthy" ]; do docker ps -a; sleep 60; done - - sudo ldconfig - - sleep 60 - - docker ps -a - - cd test/ - - echo exit | sqlplus sys/oracle@$DOCKER_MACHINE_IP:1521/XE as sysdba @travis $(pwd)/log/ - - cd - - - sudo chmod +x $OTP_ERTS_DIR/bin/epmd - - $OTP_ERTS_DIR/bin/epmd & - - LINKODPI=true ./rebar3 eunit - + - echo exit | sqlplus sys/travis@127.0.0.1:1521/XE as sysdba @test/travis.sql $(pwd)/log/ + - export LD_LIBRARY_PATH=./priv/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} + - ./rebar3 eunit after_success: - - lcov --directory . --capture --output-file coverage.info # capture coverage info - - lcov -r coverage.info "*.h" -o coverage_stripped.info # header files are not covered - - lcov --list coverage_stripped.info # log coverage result - - coveralls-lcov coverage_stripped.info # uploads to coveralls + - lcov --directory . --capture --output-file coverage.info # capture coverage info + - lcov -r coverage.info "c_src/odpi/src/*.c" "*.h" -o coverage.info # header files are not covered + - lcov --list coverage.info --list-full-path # log coverage result + - coveralls-lcov coverage.info # uploads to coveralls diff --git a/README.md b/README.md index 5abbe7a..85f3713 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,17 @@ Oracle Call Interface driver using dirty NIFs. Requires Erlang/OTP 20 or later w ## Development Currently builds in Window, Linux and OS X +#### Create Environment variables (Windows Only) +``` +OTP_ERTS_DIR = path to erlang run time system +``` +Example `.bashrc` snippet: +```sh +... +export OTP_ERTS_DIR=$(find /usr/lib/erlang/ -maxdepth 1 -type d -name erts-*) +... +``` + ## Compile (all OSs) ```sh @@ -51,19 +62,6 @@ lcov --directory . --capture --output-file coverage.info lcov --list coverage.info ``` -#### Create Environment variables -``` -OTP_ERTS_DIR = path to erlang run time system -ERL_INTERFACE_DIR = path to erl_interface or erlang installation -``` -Example `.bashrc` snippet: -```sh -... -export OTP_ERTS_DIR=$(find /usr/lib/erlang/ -maxdepth 1 -type d -name erts-*) -export ERL_INTERFACE_DIR=$(find /usr/lib/erlang/lib/ -maxdepth 1 -type d -name erl_interface-*) -... -``` - ## Testing There are some eunit tests which can be executed through `rebar3 do clean, compile, eunit` (Oracle Server connect info **MUST** be supplied through `tests/connect.config` first). @@ -73,8 +71,8 @@ C:\> sqlplus system ``` ```sql EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE); +alter session set "_ORACLE_SCRIPT"=true; -- mandatory >= Oracle 12c create user scott identified by tiger; -alter session set "_ORACLE_SCRIPT"=true; -- if 'create user scott...' results into ORA-65096 grant alter system to scott; grant create session to scott; diff --git a/c_src/Makefile b/c_src/Makefile index 0d94422..60369f8 100644 --- a/c_src/Makefile +++ b/c_src/Makefile @@ -1,10 +1,7 @@ O = priv S = c_src ODPI_REPO = https://github.com/K2InformaticsGmbH/odpi - -ifndef OTP_ERTS_DIR -$(error OTP_ERTS_DIR is not set) -endif +ERTS_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~ts/erts-~ts/\", [code:root_dir(), erlang:system_info(version)]).") SRCS = $(wildcard $(S)/*.c) ODPIROOT = $(S)/odpi @@ -12,7 +9,7 @@ ODPI_LIB_DIR = $(S)/odpi/lib TARGET = $(O)/dpi_nif.so -INCLUDEDIRS = -I$(S) -I"$(OTP_ERTS_DIR)/include" -I"$(S)/odpi/include" +INCLUDEDIRS = -I$(S) -I"$(ERTS_DIR)/include" -I"$(S)/odpi/include" CFLAGS = $(INCLUDEDIRS) -O2 -ggdb -Wall -fPIC -std=c11 LDFLAGS = -shared diff --git a/test/travis.sql b/test/travis.sql index 388e54f..66fd66d 100644 --- a/test/travis.sql +++ b/test/travis.sql @@ -16,7 +16,7 @@ SET VERIFY OFF DEFINE logfile_dir = &1 host mkdir &&logfile_dir -CONNECT system/oracle@0.0.0.0:1521/xe +CONNECT system/travis@0.0.0.0:1521/xe SET SHOWMODE OFF DEFINE spool_file = &&logfile_dir.hr_main.log