diff --git a/documentation/GUIDELINES.txt b/documentation/GUIDELINES.txt new file mode 100644 index 0000000000..2fb6a39cc8 --- /dev/null +++ b/documentation/GUIDELINES.txt @@ -0,0 +1,48 @@ +File to cover guidelines for NEO project. + +[============================================================================] + C++ usage +[============================================================================] + +- use c++ style casts instead of c style casts. +- do not use default parameters +- prefer using over typedef +- avoid defines for constants, use constexpr +- prefer forward declarations in headers +- avoid includes in headers unless absolutely necessary + +[============================================================================] + Naming conventions +[============================================================================] + +- use camelCase for variables names + +- prefer verbose variable names +bad examples : sld, elws, aws +good examples : sourceLevelDebugger, enqueuedLocalWorkGroupSize, actualWorkGroupSize + +- follow givenWhenThen test naming pattern, indicate what is interesting in the test + +bad examples : +TEST(CsrTests, initialize) +TEST(CQTests, simple) +TEST(CQTests, basic) +TEST(CQTests, works) + +good examples: +TEST(CommandStreamReceiverTests, givenCommandStreamReceiverWhenItIsInitializedThenProperFieldsAreSet) +TEST(CommandQueueTests, givenCommandQueueWhenEnqueueIsDoneThenTaskLevelIsModifed) +TEST(CommandQueueTests, givenCommandQueueWithDefaultParamtersWhenEnqueueIsDoneThenTaskCountIncreases) +TEST(CommandQueueTests, givenCommandQueueWhenEnqueueWithBlockingFlagIsSetThenDriverWaitsUntilAllCommandsAreCompleted) + +[============================================================================] + Testing mindset +[============================================================================] + +- Test behaviors instead of implementations, do not focus on adding a test per every function in the +class (avoid tests for setters and getters), focus on the functionality you are adding and how it changes +the driver behavior, do not bind tests to implementation. + +- Make sure that test is fast, our test suite needs to complete in seconds for efficient development pace, as +a general rule test shouldn't be longer then 1ms in Debug driver. + diff --git a/runtime/guidelines/CMakeLists.txt b/runtime/guidelines/CMakeLists.txt new file mode 100644 index 0000000000..8a4eb18747 --- /dev/null +++ b/runtime/guidelines/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) 2018, Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +set(RUNTIME_CODING_GUIDELINES + ${CMAKE_CURRENT_SOURCE_DIR}/../../documentation/GUIDELINES.txt +) +target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_CODING_GUIDELINES}) +set_property(GLOBAL PROPERTY RUNTIME_CODING_GUIDELINES ${RUNTIME_CODING_GUIDELINES})