commit 9dd2b0dd46fc4f16f814a00e359df0b34c750793 Author: jarjar Date: Mon Mar 3 21:03:31 2025 +0100 first commit diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7857c14 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.7 FATAL_ERROR) + +# --------------------------------------------------------------------------- +# Test Project +# --------------------------------------------------------------------------- + +project(Test + LANGUAGES + CXX + C +) + +# specify the C++ standard +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# Generates the test runner +add_executable(Test + ${CMAKE_SOURCE_DIR}/src/test.cpp + ${CMAKE_SOURCE_DIR}/src/features.cpp + ${CMAKE_SOURCE_DIR}/src/platform_linux.c +) +target_include_directories(Test PRIVATE + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/include +) + +# Generates the getplatform bin +add_executable(GetPlatform + ${CMAKE_SOURCE_DIR}/src/main.c + ${CMAKE_SOURCE_DIR}/src/platform_linux.c +) +target_include_directories(GetPlatform PRIVATE + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/include +) \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..5297489 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,29 @@ +pipeline { + agent any + stages { + stage('Config') { + steps { + dir('build') { + sh ''' + cmake --version + cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug .. + '''.stripIndent() + } + } + } + stage('Build') { + steps { + sh ''' + cmake --build build --config Debug --target Test + '''.stripIndent() + } + } + stage('Run Test') { + steps { + sh ''' + ./build/Test + '''.stripIndent() + } + } + } +} diff --git a/include/nerd/features.h b/include/nerd/features.h new file mode 100755 index 0000000..3eda1f9 --- /dev/null +++ b/include/nerd/features.h @@ -0,0 +1,20 @@ +/*------------------------------------------------------------------------* + Project: Support Recruitment Test + + Copyright (C) 2022 Nintendo, All rights reserved. + + These coded instructions, statements, and computer programs contain proprietary + information of Nintendo and/or its licensed developers and are protected by + national and international copyright laws. They may not be disclosed to third + parties or copied or duplicated in any form, in whole or in part, without the + prior written consent of Nintendo. + + The content herein is highly confidential and should be handled accordingly. +*------------------------------------------------------------------------*/ +#ifndef NERD_FEATURE_H +#define NERD_FEATURE_H + +extern "C" int nerd_add(int a, int b); +extern "C" int nerd_mul(int a, int b); + +#endif // NERD_FEATURE_H \ No newline at end of file diff --git a/include/nerd/platform.h b/include/nerd/platform.h new file mode 100755 index 0000000..0016f92 --- /dev/null +++ b/include/nerd/platform.h @@ -0,0 +1,19 @@ +/*------------------------------------------------------------------------* + Project: Support Recruitment Test + + Copyright (C) 2022 Nintendo, All rights reserved. + + These coded instructions, statements, and computer programs contain proprietary + information of Nintendo and/or its licensed developers and are protected by + national and international copyright laws. They may not be disclosed to third + parties or copied or duplicated in any form, in whole or in part, without the + prior written consent of Nintendo. + + The content herein is highly confidential and should be handled accordingly. +*------------------------------------------------------------------------*/ +#ifndef NERD_FEATURE_H +#define NERD_FEATURE_H + +const char *get_platform_name(); + +#endif // NERD_FEATURE_H \ No newline at end of file diff --git a/src/features.cpp b/src/features.cpp new file mode 100755 index 0000000..80d5e91 --- /dev/null +++ b/src/features.cpp @@ -0,0 +1,24 @@ +/*------------------------------------------------------------------------* + Project: Support Recruitment Test + + Copyright (C) 2022 Nintendo, All rights reserved. + + These coded instructions, statements, and computer programs contain proprietary + information of Nintendo and/or its licensed developers and are protected by + national and international copyright laws. They may not be disclosed to third + parties or copied or duplicated in any form, in whole or in part, without the + prior written consent of Nintendo. + + The content herein is highly confidential and should be handled accordingly. +*------------------------------------------------------------------------*/ +#include "nerd/features.h" + +extern "C" int nerd_add(int a, int b) +{ + return a + b; +} + +extern "C" int nerd_mul(int a, int b) +{ + return a * b; +} \ No newline at end of file diff --git a/src/main.c b/src/main.c new file mode 100755 index 0000000..cbeaaa3 --- /dev/null +++ b/src/main.c @@ -0,0 +1,22 @@ +/*------------------------------------------------------------------------* + Project: Support Recruitment Test + + Copyright (C) 2022 Nintendo, All rights reserved. + + These coded instructions, statements, and computer programs contain proprietary + information of Nintendo and/or its licensed developers and are protected by + national and international copyright laws. They may not be disclosed to third + parties or copied or duplicated in any form, in whole or in part, without the + prior written consent of Nintendo. + + The content herein is highly confidential and should be handled accordingly. +*------------------------------------------------------------------------*/ +#include + +#include "nerd/platform.h" + +int main(int argc, char **argv) +{ + printf("Hello Support from %s\n", get_platform_name()); + return 0; +} \ No newline at end of file diff --git a/src/platform_linux.c b/src/platform_linux.c new file mode 100755 index 0000000..c26257d --- /dev/null +++ b/src/platform_linux.c @@ -0,0 +1,23 @@ +/*------------------------------------------------------------------------* + Project: Support Recruitment Test + + Copyright (C) 2022 Nintendo, All rights reserved. + + These coded instructions, statements, and computer programs contain proprietary + information of Nintendo and/or its licensed developers and are protected by + national and international copyright laws. They may not be disclosed to third + parties or copied or duplicated in any form, in whole or in part, without the + prior written consent of Nintendo. + + The content herein is highly confidential and should be handled accordingly. +*------------------------------------------------------------------------*/ +#include "nerd/platform.h" + +#ifndef __linux__ +#error the linux platform file is compiled with an incompatible compiler +#endif + +const char *get_platform_name() +{ + return "Linux"; +} diff --git a/src/test.cpp b/src/test.cpp new file mode 100755 index 0000000..4aba787 --- /dev/null +++ b/src/test.cpp @@ -0,0 +1,110 @@ +/*------------------------------------------------------------------------* + Project: Support Recruitment Test + + Copyright (C) 2022 Nintendo, All rights reserved. + + These coded instructions, statements, and computer programs contain proprietary + information of Nintendo and/or its licensed developers and are protected by + national and international copyright laws. They may not be disclosed to third + parties or copied or duplicated in any form, in whole or in part, without the + prior written consent of Nintendo. + + The content herein is highly confidential and should be handled accordingly. +*------------------------------------------------------------------------*/ +#include "nerd/features.h" + +#include + +#if __cplusplus != 201103L +#error The source is not compiled in c++11 mode +#endif + +#include + +#define ASSERT_EQUAL(a, b) \ + do \ + { \ + if ((a) != (b)) \ + { \ + std::cerr << "FAILURE: expected " #a "=" << (a) << " got " #b "=" << (b) << "\n"; \ + return false; \ + } \ + } while (0) + +namespace +{ + bool test_add() + { + for (int i = 0; i < 512; ++i) + { + for (int j = 0; j < 512; ++j) + { + int expected = i + j; + int result = nerd_add(i, j); + ASSERT_EQUAL(expected, result); + } + } + + return true; + } + + bool test_mul() + { + for (int i = 0; i < 512; ++i) + { + for (int j = 0; j < 512; ++j) + { + int expected = i * j; + int result = nerd_mul(i, j); + ASSERT_EQUAL(expected, result); + } + } + + return true; + } + + bool test_fail() + { + return false; + } +} // namespace anonymous + +extern "C" int main(int argc, char **argv) +{ + std::cout << "Test program\n"; + + struct + { + const char *name; + bool (*func)(); + } test_list[] = { + {"Addition", test_add}, + {"Multiplication", test_mul}, + {"WontWork", test_fail}}; + static constexpr auto test_list_len = sizeof(test_list) / sizeof(test_list[0]); + + bool success = true; + size_t failures = 0; + size_t successes = 0; + + size_t i; + for (i = 0; i < test_list_len; ++i) + { + bool result = test_list[i].func(); + if (result) + { + std::cout << "[ SUCCESS ] TestSuite." << test_list[i].name << "\n"; + successes++; + } + else + { + std::cout << "[ FAILURE ] TestSuite." << test_list[i].name << "\n"; + failures++; + } + success = success && result; + } + + std::cout << "[ RESULTS ] " << successes << "/" << i << "\n"; + + return success ? EXIT_SUCCESS : EXIT_FAILURE; +} \ No newline at end of file