Query related to script file which generates Testing folder

I am looking into building ROS 2.0 by enabling its tests and have realised that for each package of ROS in the build folder, a corresponding Testing folder is being created, which contains LogTest_xxx.log and LastTestsFailed_xxx.log files.

I want to know which script is responsible for generating this folder and its corresponding log files.

That mus be launch_testing. In GitHub you can search for org:ros2 launch_testing (will usually find <test_depend>launch_testing</test_depend> in package.xml files) to figure out which packages make use of this current ROS2 node level testing tool.

launch_testing has nothing to do with these files.

They are being generated by CTest so this will be present in an CMake based package after invoking the tests through CTest.