From d4758962e3c72eb358556c29b13400f5621bbd2d Mon Sep 17 00:00:00 2001 From: Vadim Volodin Date: Thu, 2 Dec 2021 03:48:39 +0300 Subject: [PATCH] Update DEVNOTE.md: provide more details about docker login, cloning repo and troubleshooting --- DEVNOTE.md | 60 ++++++++++++++++++++++++++++++-------- build.sh | 0 docker/utbot_docker_dev.sh | 2 +- vscode-plugin/build.sh | 0 4 files changed, 49 insertions(+), 13 deletions(-) mode change 100644 => 100755 build.sh mode change 100644 => 100755 docker/utbot_docker_dev.sh mode change 100644 => 100755 vscode-plugin/build.sh diff --git a/DEVNOTE.md b/DEVNOTE.md index 838482ee2..f34eaea84 100644 --- a/DEVNOTE.md +++ b/DEVNOTE.md @@ -2,7 +2,7 @@ UTBot has many dependencies, so the easiest way to build the tool from source and develop it is to use the docker container. -UTBot has a published package called [base_env](https://github.com/UnitTestBot/UTBotCpp/pkgs/container/utbotcpp%2Fbase_env). +UTBot has a published package called [base_env](https://github.com/UnitTestBot/UTBotCpp/pkgs/container/utbotcpp%2Fbase_env). It contains all the needed dependencies such as Git, LLVM, GRPC, GoogleTest and so on. **base_env** has multiple versions tagged with dates. If you are developing the tool, you are most likely to need the most recent version. @@ -12,24 +12,26 @@ To build UTBot from sources: ``` docker plugin install lebokus/bindfs ``` -3. Run `utbot_docker_dev.sh` script. It will unpack the docker image and mount UTBot sources inside it. +3. You need to do `docker login` to `ghcr.io` as described [here](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry). +4. Run `utbot_docker_dev.sh` [script](https://github.com/UnitTestBot/UTBotCpp/blob/main/docker/utbot_docker_dev.sh). It will unpack the docker image and mount UTBot sources inside it. UTBot binary can be built in the docker and run in it. - The script will prompt you to enter an `ssh` port required to ssh into the container using `ssh utbot@host -p $port`, where `host` is docker host IP address (it may be `localhost`). Please, specify a port that is not taken by any process. Also, you will be prompted to enter a port where UTBot itself will be run. -4. Get access to the container via + The script will prompt you to enter docker image tag. You can find the most recent tag [here](https://github.com/UnitTestBot/UTBotCpp/pkgs/container/utbotcpp%2Fbase_env), for example `24-11-2021`. Also it will ask about `ssh` port required to ssh into the container using `ssh utbot@host -p $port`, where `host` is docker host IP address (it may be `localhost`). Please, specify a port that is not taken by any process. Also, you will be prompted to enter a port where UTBot itself will be run. +5. Get access to the container via `ssh utbot@host -p $port` If you are prompted a password, type in `utbot`. -5. `cd` into `UTBotCpp` directory and run `build.sh` — it is the script that builds KLEE UTBot and runs UTBot unit tests -6. Navigate to `UTBotCpp/server/build` directory and launch the binary with `./utbot server` command. Now the server is running. -7. Launch VS Code on your local machine. Use VS Code [Remote-SSH](https://code.visualstudio.com/docs/remote/ssh) to get access to the docker insides. Navigate to `UTBotCpp/vscode-plugin` directory and run `build.sh` script. -8. Press F5 (*Run Extension*). This will run UTBot VS Code plugin. -9. A new VS Code window will open; this window will have UTBot VS Code plugin enabled. In this new folder, open `UTBotCpp/integration-tests/c-example` directory. -10. When UTBot Quickstart Wizard requests you to enter server host and port, specify `localhost` and UTBot server run port, respectively. +5. Clone UTBotCpp repository into home directory inside docker container, preferably with ssh. And don't forget to clone modules with `git submodule update --init --recursive` +6. `cd` into `UTBotCpp` directory and run `build.sh` — it is the script that builds KLEE UTBot and runs UTBot unit tests +7. Navigate to `UTBotCpp/server/build` directory and launch the binary with `./utbot server` command. Now the server is running. +8. Launch VS Code on your local machine. Use VS Code [Remote-SSH](https://code.visualstudio.com/docs/remote/ssh) to get access to the docker insides. Navigate to `UTBotCpp/vscode-plugin` directory and run `build.sh` script. +9. Press F5 (*Run Extension*). This will run UTBot VS Code plugin. +10. A new VS Code window will open; this window will have UTBot VS Code plugin enabled. In this new folder, open `UTBotCpp/integration-tests/c-example` directory. +11. When UTBot Quickstart Wizard requests you to enter server host and port, specify `localhost` and UTBot server run port 2121, respectively. ![Oops, something went wrong! Please look at wizardInstall.gif](media/wizardInstall.gif "UTBot Wizard Demo") -11. Select project path as `/home/utbot/UTBotCpp/integration-tests/c-example`; -12. You are now ready to experience UTBot capabilities! You can view possible commands in Command Palette (Press F1 and type in UTBot). +12. Select project path as `/home/utbot/UTBotCpp/integration-tests/c-example`; +13. You are now ready to experience UTBot capabilities! You can view possible commands in Command Palette (Press F1 and type in UTBot). If you want to change UTBot test generation preferences, you can edit them in File > Preferences > Settings > Extensions > UnitTestBot. After UTBot configuration, you can select your source directories with the tab on the VSCode toolbar on the left. Then, you can generate tests with the use of Command Palette. Press **F1** and type in "UTBot": You will see tests generation options. @@ -45,3 +47,37 @@ To setup it: 4. In *Credentials* section, set up an `ssh` connection to the UTBot docker container you have. Consider enabling connection via OpehSSH authentification agent to ease files synchronization. 5. All other fields should fill in automatically. + +## Troubleshooting the build +### read -i invalid option +You can experience this on Mac OS: +```shell +read: -i: invalid option +``` +It is because Mac OS has too old bash version. Upgrade bash version and set it to default: +```shell +brew install bash +chsh -s /usr/local/bin/bash +``` +### Problem with gRPC +If you experience this problem: +```shell +--grpc_out: protoc-gen-grpc: Plugin failed with status code 1. +/bin/grpc_cpp_plugin: program not found or is not executable +``` +```shell +ninja: error: 'protobuf/testgen.grpc.pb.h', needed by 'CMakeFiles/utbot.dir/main.cpp.o', missing and no known rule to make it +``` +Copy the program to /bin: +```shell +cp /utbot_distr/install/bin/grpc_cpp_plugin /bin/ +``` +### Error while mounting empty volume +If this error happens on Mac OS: +```shell +docker: Error response from daemon: error while mounting volume '': VolumeDriver.Mount: exit status 1%!(EXTRA []interface {}=[]). +``` +Remove the following line in utbot_docker_dev.sh: +```shell + -v $MOUNT_LOCAL_NAME:/home/utbot/mnt \ +``` \ No newline at end of file diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/docker/utbot_docker_dev.sh b/docker/utbot_docker_dev.sh old mode 100644 new mode 100755 index 583db9d33..db659b29e --- a/docker/utbot_docker_dev.sh +++ b/docker/utbot_docker_dev.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved. diff --git a/vscode-plugin/build.sh b/vscode-plugin/build.sh old mode 100644 new mode 100755