Programming in C++ - Credit/Exam Tests

Credit tests and exams

The credit tests and exams take place in a computer lab (S[UW][12] or N8/N11). To ensure equal environment, students must use only the computers of the lab, either in Windows or in Linux mode. The use of notebooks (or other computing devices not installed in the lab) is not allowed during the credit/exam tests. Students shall not use any resource other than the compiler, debugger, editor and/or IDE installed at the lab, their documentation, and the language reference manuals at cppreference.com.

Each student must work independently.

Before attempting a test

Make sure that you can log in to local PCs in the labs. You shall use your CAS/SIS login; however, some unverified/expired/reset CAS logins may not work here.

Make sure that you are familiar with the development environment at the lab computers. (See also below.)

NEW: You may also use some crowd-sourced resources to improve the lab environment, collected at the bottom of this page.

For this purpose, the SU1 lab is available at most times.

Restricted environment in the labs

During credit/exam tests, the lab computers will be configured into a restrictive environment:

Warning: If you log-off, your computer crashes, or the end-of-test time passes, you will lose all your files.
Submit your sources into Recodex frequently, even if incomplete.
Recodex is your only backup.

Restricted access to Recodex during exams

During credit test, the corresponding tutorial group in Recodex will be in Exam mode. It means that the students of this group (including those not present at the test) will not be able to access the group in Recodex, unless they lock themselves to a particular computer by pressing a special button in Recodex.

After locking, you will be able to access the credit test assignment as well as all assignments in the same group, i.e. your previous homeworks. It will allow you to download your code from the last home assignment as the base for your credit test. You can also access your code from other homeworks in this course and semester.

If you need to switch your seat during the test (e.g. due to a computer failure), you must ask the teacher to be released from the lock, then lock again at the new seat. Your source code in recodex will be preserved.

At exam test, the arrangement will be similar; however, you will not be able to access your previous homeworks or tests because the exam will happen in a dedicated group different from your tutorial group.

Development tools in the labs

You can select Windows or Linux by rebooting the computer.

C++ development tools known to work in the restricted environment:

  • Windows:
    • Visual Studio 2022
    • VS Code (make sure the C/C++, C/C++ - Extension Pack and CMake Tools extensions by Microsoft are enabled)
  • Linux:

Hints

  • Build environment - setting-up the project
    • Code::Blocks
      "New Project", select category "Console", then "Empty Project".
    • kdevelop
      "New Project", select category "Standard", type "Terminal", then "CMake C++".
    • cmake (VS Code; also Visual Studio in Folder mode)
      • Create file CMakeLists.txt
        cmake_minimum_required(VERSION 3.20)
        project("labtest")
        
        add_executable("my_prog" "source.cpp")
        
        set_property(TARGET "my_prog" PROPERTY CXX_STANDARD 23)
        
      • VS Code: Go to menu item "View" > "Command Palette", search for "CMake: Show Configure Command"; then use Build icon at the bottom VSCode toolbar.
        Note: The Debug and Run icons to the right of the Build icon ignore the argument setting in launch.json. In addition, in our labs, none of the Debug commands/icons work.
  • Debugging - set-up the program and arguments
    • Code::Blocks
      Go to the menu "Project" > "Set program's arguments".
    • kdevelop
      Go to menu item "Run" > "Configure launches", highlight the project you want to add a launch for, and click on the "+" button.
    • Visual Studio in project mode
      Go to the menu "PROJECT" > "Properties", then set "Debugging" > "Command Arguments". Also make sure that "Working Directory" is set to "$(ProjectDir)".
    • Visual Studio in Folder mode:
      Go to the menu "DEBUG" > "Debug and launch settings", then edit launch.json as in this example:
      {
          "version": "0.2.1",
          "defaults": {},
          "configurations": [
            {
              "type": "default",
              "project": "CMakeLists.txt",
              "projectTarget": "my_prog.exe",
              "name": "my_prog.exe",
              "currentDir": ".",
              "args": [ "expr1.txt", "input1.csv", "output1.csv" ]
            }
          ]
        }
      
    • VS Code in Windows:
      Go to the menu "Run" > "Add configuration", select "(Windows) launch", and edit .vscode/launch.json as in this example:
      {
          "version": "0.2.0",
          "configurations": [
          {
              "name": "(Windows) Launch",
              "type": "cppvsdbg",
              "request": "launch",
              "program": "${workspaceFolder}/build/Debug/my_prog.exe",
              "args": ["expr1.txt", "input1.csv", "output1.csv"],
              "stopAtEntry": true,
              "cwd": "${workspaceFolder}",
              "environment": [],
              "console": "externalTerminal"
          }
          ]
      }
      
    • VS Code in Linux:
      Go to the menu "Run" > "Add configuration", select "(gdb) launch", and edit .vscode/launch.json as in this example:
      {
          "version": "0.2.0",
          "configurations": [
          {
              "name": "(gdb) Launch",
              "type": "cppdbg",
              "request": "launch",
              "program": "${workspaceFolder}/build/my_prog",
              "args": ["expr1.txt", "input1.csv", "output1.csv"],
              "stopAtEntry": true,
              "cwd": "${workspaceFolder}",
              "environment": [],
              "externalConsole": false,
              "MIMode": "gdb",
              "setupCommands": [
                  {
                      "description": "Enable pretty-printing for gdb",
                      "text": "-enable-pretty-printing",
                      "ignoreFailures": true
                  },
                  {
                      "description": "Set Disassembly Flavor to Intel",
                      "text": "-gdb-set disassembly-flavor intel",
                      "ignoreFailures": true
                  }
              ]
          }
          ]
      }
      

Various useful resources

  • vim settings ((C) Jan Černohorský):
    • cpp.vim - vim setting suitable for C++
    • clangd.lua - neovim plugin to enable clangd-based suggestions etc.
    Look for comments inside the files for details.
  • VS Code - clangd extension:
    • vscode-clangd-0.1.33.vsix - go to `View` in the menu bar and select `Extensions` in Visual Studio Code, in the Extensions panel, use the top right button (labelled with three dots) to see more actions and select `Install from VSIX...`
    Visual Studio Code may warn you that you have both `Microsoft C++` and `clangd` extensions enabled. The `Disable IntelliSense` button will disable `Microsoft C++` IntelliSense. Then, click the `Reload` button to reload the workspace and `clangd` should work correctly.

If you have a setting or similar resource that could help someone during the test or exam, it may be placed here, on the condition that it is documented so that it may be useful to everyone. Just send it by email.