1import os 2 3import infra.basetest 4 5 6class TestNodeJSBasic(infra.basetest.BRTest): 7 config = \ 8 """ 9 BR2_arm=y 10 BR2_cortex_a9=y 11 BR2_ARM_ENABLE_VFP=y 12 BR2_TOOLCHAIN_EXTERNAL=y 13 BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y 14 BR2_PACKAGE_NODEJS=y 15 BR2_TARGET_ROOTFS_CPIO=y 16 # BR2_TARGET_ROOTFS_TAR is not set 17 BR2_ROOTFS_POST_BUILD_SCRIPT="{}" 18 BR2_ROOTFS_POST_SCRIPT_ARGS="{}" 19 """.format(infra.filepath("tests/package/copy-sample-script-to-target.sh"), 20 infra.filepath("tests/package/sample_nodejs_basic.js")) 21 22 def test_run(self): 23 cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") 24 self.emulator.boot(arch="armv7", 25 kernel="builtin", 26 options=["-initrd", cpio_file]) 27 self.emulator.login() 28 self.assertRunOk("node sample_nodejs_basic.js") 29 30 31class TestNodeJSModuleHostBin(infra.basetest.BRTest): 32 config = \ 33 """ 34 BR2_arm=y 35 BR2_cortex_a9=y 36 BR2_ARM_ENABLE_VFP=y 37 BR2_TOOLCHAIN_EXTERNAL=y 38 BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y 39 BR2_PACKAGE_NODEJS=y 40 BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL="lodash" 41 BR2_PACKAGE_HOST_NODEJS_BIN=y 42 BR2_TARGET_ROOTFS_CPIO=y 43 # BR2_TARGET_ROOTFS_TAR is not set 44 BR2_ROOTFS_POST_BUILD_SCRIPT="{}" 45 BR2_ROOTFS_POST_SCRIPT_ARGS="{}" 46 """.format(infra.filepath("tests/package/copy-sample-script-to-target.sh"), 47 infra.filepath("tests/package/sample_nodejs_module.js")) 48 49 def test_run(self): 50 cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") 51 self.emulator.boot(arch="armv7", 52 kernel="builtin", 53 options=["-initrd", cpio_file]) 54 self.emulator.login() 55 self.assertRunOk("node sample_nodejs_module.js") 56 57 58class TestNodeJSModuleHostSrc(infra.basetest.BRTest): 59 config = \ 60 """ 61 BR2_arm=y 62 BR2_cortex_a9=y 63 BR2_ARM_ENABLE_VFP=y 64 BR2_TOOLCHAIN_EXTERNAL=y 65 BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y 66 BR2_PACKAGE_NODEJS=y 67 BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL="lodash" 68 BR2_PACKAGE_HOST_NODEJS_SRC=y 69 BR2_TARGET_ROOTFS_CPIO=y 70 # BR2_TARGET_ROOTFS_TAR is not set 71 BR2_ROOTFS_POST_BUILD_SCRIPT="{}" 72 BR2_ROOTFS_POST_SCRIPT_ARGS="{}" 73 """.format(infra.filepath("tests/package/copy-sample-script-to-target.sh"), 74 infra.filepath("tests/package/sample_nodejs_module.js")) 75 76 def test_run(self): 77 cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") 78 self.emulator.boot(arch="armv7", 79 kernel="builtin", 80 options=["-initrd", cpio_file]) 81 self.emulator.login() 82 self.assertRunOk("node sample_nodejs_module.js") 83