Currently, the get_srcdir() function in cdefs.py tries to find the source directory by walking up the path from it's main module. However, this may not necessarily be located where the src directory actually is depending on how it is ran and imported. However, it also checks the SRC_DIR environment variable. This commit ensures this environment variable is always set based on the config, or an override environment variable. This way cdefs.py can always find the sources files it requires.
I don't, but this is fixing incongruent behavior between get_srcdir() and the main script here. As for the environment variable, depending on how the tests are ran, get_scrdir() make not be able to find the srcdir. It's not particularly nice, but setting the environment variable is a fix.