vectorgrp / vector-vscode-vcast

A VectorCAST test adapter for VS Code
Other
8 stars 2 forks source link

Missing environments when changing VectorCAST version #167

Closed aytey closed 2 months ago

aytey commented 2 months ago

This is closely related to #148 and was found by @Den1552.

Obtain VectorCAST 2023 "sp0" and VectorCAST 2024sp3; place these in a common location and update the variable vcast_root in the below script (make sure the folders are called 2023 and 2024sp3 respectively, or change old_ver/new_ver).

Run the following:

#!/bin/bash

set -eu

env_template="TEST.template"
placeholder="%%REPLACE%%"
unit="unit"

total_count=10
to_flip=05

vcast_root=${HOME}/vcast
old_ver=2023
new_ver=2024sp3

cat > ${env_template} << EOF
ENVIRO.NEW
ENVIRO.NAME: ${placeholder}
ENVIRO.STUB_BY_FUNCTION: ${unit}
ENVIRO.WHITE_BOX: NO
ENVIRO.VCDB_FILENAME:
ENVIRO.COVERAGE_TYPE: NONE
ENVIRO.LIBRARY_STUBS:
ENVIRO.STUB: ALL_BY_PROTOTYPE
ENVIRO.COMPILER: CC
ENVIRO.SEARCH_LIST: .
ENVIRO.END
EOF

cat > ${unit}.cpp << EOF
void foo(void) {}
EOF

export VCAST_FORCE_OVERWRITE_ENV_DIR=1
export VECTORCAST_DIR=${vcast_root}/${old_ver}

$VECTORCAST_DIR/clicast -lc template GNU_CPP17_X

for i in $(seq -w 1 ${total_count}); do
    env_name="ENV_${i}"
    sed "s/${placeholder}/${env_name}/g" ${env_template} > ${env_name}.env
    $VECTORCAST_DIR/clicast -lc environment script run ${env_name}.env
done

export VECTORCAST_DIR=${vcast_root}/${new_ver}
$VECTORCAST_DIR/clicast -lc environment script run ENV_${to_flip}.env

rm -rf .vscode
mkdir .vscode
cat > .vscode/settings.json << EOF
{
    "vectorcastTestExplorer.vectorcastInstallationLocation": "${vcast_root}/${old_ver}"
}
EOF

# EOF

and now open-up the folder in VS Code.

aytey commented 2 months ago

You will now see no environments

This seems to strangely update the environments to be a newer DataAPI revision.

After following the above steps, try to run (paths may vary):

/home/avj/vcast/2023/vpython /home/avj/clones/vector-vscode-vcast/main/python/vTestInterface.py --mode getEnviroData --path ENV_01

Then you'll see:

ACTUAL-DATA
Master.db (version 18) is newer than your version of VectorCAST (17).
In order to work with this environment, re-build it with an older version of
VectorCAST, or use a newer version of VectorCAST.

and now you can't open the environment with 2023

aytey commented 2 months ago

and now you can't open the environment with 2023

This reproduces it (make sure you set vcast_root/old_ver/new_ver/vscode_repo):

vcast_root=${HOME}/vcast
old_ver=2023
new_ver=2024sp3

vscode_repo=${HOME}/clones/vector-vscode-vcast/main

export VCAST_FORCE_OVERWRITE_ENV_DIR=1
export VECTORCAST_DIR=${vcast_root}/${old_ver}
$VECTORCAST_DIR/enviroedg ENV_01.env
$VECTORCAST_DIR/vpython ${vscode_repo}/python/vTestInterface.py --mode getEnviroData --path ENV_01

export VECTORCAST_DIR=${vcast_root}/${new_ver}
$VECTORCAST_DIR/vpython ${vscode_repo}/python/vTestInterface.py --mode getEnviroData --path ENV_01

export VECTORCAST_DIR=${vcast_root}/${old_ver}
$VECTORCAST_DIR/vpython ${vscode_repo}/python/vTestInterface.py --mode getEnviroData --path ENV_01
aytey commented 2 months ago

Now configure the extension to use "${vcast_root}/${new_ver}" (i.e., 2024sp3) for the VectorCAST version You will now see only one environment (only ENV_05)

Okay, so this seems legitimate:

Traceback (most recent call last):
  File "/home/avj/clones/vector-vscode-vcast/main/python/vTestInterface.py", line 609, in <module>
    returnCode = main()
  File "/home/avj/clones/vector-vscode-vcast/main/python/vTestInterface.py", line 589, in main
    returnCode, returnObject = processCommand(
  File "/home/avj/clones/vector-vscode-vcast/main/python/vTestInterface.py", line 539, in processCommand
    topLevel["testData"] = getTestDataVCAST(pathToUse)
  File "/home/avj/clones/vector-vscode-vcast/main/python/vTestInterface.py", line 192, in getTestDataVCAST
    coverageType = api.environment.coverage_type_text
  File "vector/apps/DataAPI/unit_test_models.py", line 2162, in coverage_type_text
  File "vector/apps/DataAPI/unit_test_models.py", line 4961, in coverage_type_text
  File "vector/apps/DataAPI/unit_test_models.py", line 4769, in _delegate_to_cover
  File "vector/apps/DataAPI/unit_test_models.py", line 4840, in cover_data
  File "vector/apps/DataAPI/unit_test_models.py", line 177, in get_coverdb_api
  File "vector/apps/DataAPI/unit_test_models.py", line 1948, in coverdb_api
  File "vector/apps/DataAPI/cover_api.py", line 157, in __init__
  File "_databases.pyx", line 19, in _databases.BasicDB.__init__
  File "vector/apps/DataAPI/coverdb.py", line 5279, in initialize
RuntimeError: cover.db (version 62) is too old to use with this module.
Run clicast or vcastqt on your environment to update it first.

The only bug here is "and now you can't open the environment with 2023", which is a VectorCAST bug.

This can be closed.