#!/bin/bash

test=testEDAlias

function die { echo Failure $1: status $2 ; exit $2 ; }

LOCAL_TEST_DIR=${SCRAM_TEST_PATH}

  echo "*************************************************"
  echo "EDAlias consumer in a Task"
  cmsRun ${LOCAL_TEST_DIR}/${test}Task_cfg.py || die "cmsRun ${test}Task_cfg.py 1" $?

  echo "*************************************************"
  echo "Test EDAlias aliasing for many modules"
  cmsRun ${LOCAL_TEST_DIR}/${test}ManyModules_cfg.py || die "cmsRun ${test}ManyModules_cfg.py 1" $?

  echo "*************************************************"
  echo "Test EDAlias aliasing for many modules with possibly ambiguous get via edm::View"
  cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py && die "cmsRun ${test}ManyModulesAmbiguous_cfg.py 1" 1
  cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py includeAliasToFoo=0 || die "cmsRun ${test}ManyModulesAmbiguous_cfg.py includeAliasToFoo=0" $?
  cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py includeAliasToBar=0 || die "cmsRun ${test}ManyModulesAmbiguous_cfg.py includeAliasToBar=0" $?
  cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py consumerGets=0 || die "cmsRun ${test}ManyModulesAmbiguous_cfg.py consumerGets=0" $?
  cmsRun ${LOCAL_TEST_DIR}/${test}ManyModulesAmbiguous_cfg.py explicitProcessName=1 && die "cmsRun ${test}ManyModulesAmbiguous_cfg.py explicitProcessName=1" 1

exit 0
