added few TCs for nodejs-devel

This commit is contained in:
Andrei Radchenko 2025-01-10 16:02:27 +01:00
commit 2de7eb22a3
6 changed files with 158 additions and 0 deletions

View file

@ -0,0 +1,21 @@
#include <node.h>
namespace demo {
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
void Method(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "Hello from native addon!").ToLocalChecked());
}
void Initialize(Local<Object> exports) {
NODE_SET_METHOD(exports, "hello", Method);
}
NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)
}

View file

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

View file

@ -0,0 +1,52 @@
#!/bin/bash
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Author: Andrei Radchenko <aradchen@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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

View file

@ -0,0 +1,3 @@
const addon = require('./addon.node');
console.log(addon.hello()); // Should print: Hello from native addon!

View file

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

View file

@ -0,0 +1,47 @@
#!/bin/bash
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Author: Andrei Radchenko <aradchen@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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