From 2de7eb22a345603f633204f8b418bf4f834f7d3c Mon Sep 17 00:00:00 2001 From: Andrei Radchenko Date: Fri, 10 Jan 2025 16:02:27 +0100 Subject: [PATCH] added few TCs for nodejs-devel --- Integration/nodejs-devel-build/addon.cc | 21 +++++++++ Integration/nodejs-devel-build/main.fmf | 17 ++++++++ Integration/nodejs-devel-build/runtest.sh | 52 +++++++++++++++++++++++ Integration/nodejs-devel-build/test.js | 3 ++ Smoke/nodejs-devel-smoke/main.fmf | 18 ++++++++ Smoke/nodejs-devel-smoke/runtest.sh | 47 ++++++++++++++++++++ 6 files changed, 158 insertions(+) create mode 100644 Integration/nodejs-devel-build/addon.cc create mode 100644 Integration/nodejs-devel-build/main.fmf create mode 100755 Integration/nodejs-devel-build/runtest.sh create mode 100644 Integration/nodejs-devel-build/test.js create mode 100644 Smoke/nodejs-devel-smoke/main.fmf create mode 100755 Smoke/nodejs-devel-smoke/runtest.sh diff --git a/Integration/nodejs-devel-build/addon.cc b/Integration/nodejs-devel-build/addon.cc new file mode 100644 index 0000000..84c9c9f --- /dev/null +++ b/Integration/nodejs-devel-build/addon.cc @@ -0,0 +1,21 @@ +#include + +namespace demo { + using v8::FunctionCallbackInfo; + using v8::Isolate; + using v8::Local; + using v8::Object; + using v8::String; + using v8::Value; + + void Method(const FunctionCallbackInfo& args) { + Isolate* isolate = args.GetIsolate(); + args.GetReturnValue().Set(String::NewFromUtf8(isolate, "Hello from native addon!").ToLocalChecked()); + } + + void Initialize(Local exports) { + NODE_SET_METHOD(exports, "hello", Method); + } + + NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize) +} diff --git a/Integration/nodejs-devel-build/main.fmf b/Integration/nodejs-devel-build/main.fmf new file mode 100644 index 0000000..b713c82 --- /dev/null +++ b/Integration/nodejs-devel-build/main.fmf @@ -0,0 +1,17 @@ +summary: Test to insure native modules can be built using nodejs-devel. +test: ./runtest.sh +framework: beakerlib +description: | + Nodejs-devel provides some libraries needed for building some nodejs-related packages. + This test insures they are present and can be used to build a module. +duration: 5m +require: + - nodejs-devel + - nodejs + - gcc-c++ +contact: + - aradchen@redhat.com + - tjuhasz@redhat.com +tag: integration +component: + - nodejs-devel diff --git a/Integration/nodejs-devel-build/runtest.sh b/Integration/nodejs-devel-build/runtest.sh new file mode 100755 index 0000000..cec3ece --- /dev/null +++ b/Integration/nodejs-devel-build/runtest.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Author: Andrei Radchenko +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +NODE_LIBS_PATH='/usr/include/node' + +rlJournalStart + rlPhaseStartSetup + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "mv addon.cc test.js $tmp" 0 "Moving working files" + rlRun "pushd $tmp" + rlPhaseEnd + + rlPhaseStartTest + rlShowPackageVersion nodejs-devel + rlShowPackageVersion nodejs + rlAssertExists "$NODE_LIBS_PATH/node.h" + rlAssertExists "$NODE_LIBS_PATH/v8.h" + rlRun "g++ -o addon.node -shared -fPIC -I/usr/include/node addon.cc" 0 "Trying to manually build native module" + rlRun "node ./test.js >> output" 0 "Trying to resolve new module" + rlAssertGrep "Hello from native addon!" output + rlPhaseEnd + + rlPhaseStartCleanup + rlLogInfo "Deleting temp files" + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd + +rlJournalEnd diff --git a/Integration/nodejs-devel-build/test.js b/Integration/nodejs-devel-build/test.js new file mode 100644 index 0000000..59608fd --- /dev/null +++ b/Integration/nodejs-devel-build/test.js @@ -0,0 +1,3 @@ +const addon = require('./addon.node'); + +console.log(addon.hello()); // Should print: Hello from native addon! diff --git a/Smoke/nodejs-devel-smoke/main.fmf b/Smoke/nodejs-devel-smoke/main.fmf new file mode 100644 index 0000000..42188fc --- /dev/null +++ b/Smoke/nodejs-devel-smoke/main.fmf @@ -0,0 +1,18 @@ +summary: Test to insure devel libraries installed +test: ./runtest.sh +framework: beakerlib +description: | + Nodejs-devel provides some libraries needed for building some nodejs-related packages. + this test insures they are present after installation. +duration: 5m +require: + - nodejs-devel +# - type: file +# pattern: +# - /template.file +contact: + - aradchen@redhat.com + - tjuhasz@redhat.com +tag: smoke +component: + - nodejs-devel diff --git a/Smoke/nodejs-devel-smoke/runtest.sh b/Smoke/nodejs-devel-smoke/runtest.sh new file mode 100755 index 0000000..8181833 --- /dev/null +++ b/Smoke/nodejs-devel-smoke/runtest.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Author: Andrei Radchenko +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +NODE_LIBS_PATH='/usr/include/node' + +rlJournalStart + rlPhaseStartSetup + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "pushd $tmp" + rlPhaseEnd + + rlPhaseStartTest + rlShowPackageVersion nodejs-devel + rlAssertExists "$NODE_LIBS_PATH/node.h" + rlAssertExists "$NODE_LIBS_PATH/v8.h" + rlPhaseEnd + + rlPhaseStartCleanup + rlLogInfo "Deleting files" + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd + +rlJournalEnd