Skip to content

Commit

Permalink
[one-cmds] Raise error when backend and target option are given (Sams…
Browse files Browse the repository at this point in the history
…ung#13340)

This commit raises an error when backend and target option are given simultaneously.

ONE-DCO-1.0-Signed-off-by: seongwoo <[email protected]>
  • Loading branch information
mhs4670go authored Jul 3, 2024
1 parent 37180b1 commit 8cf53ea
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/one-cmds/onecc
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ def verify_arg(parser: ArgumentParser, args):
if oneutils.is_valid_attr(args, 'backend') and oneutils.is_valid_attr(
args, 'workflow'):
parser.error('\'backend\' option can be used only with \'config\' option')
if oneutils.is_valid_attr(args, 'backend') and oneutils.is_valid_attr(args, 'target'):
parser.error(
'\'backend\' and \'target\' are mutually exclusive option. \'target\' option automatically set a backend.'
)
if oneutils.is_valid_attr(args, 'backend'):
verify_backend_args(parser, args)
Expand Down
41 changes: 41 additions & 0 deletions compiler/one-cmds/tests/onecc_neg_037.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# use 'backend' option with 'target' option simultaneously

filename_ext="$(basename -- $0)"
filename="${filename_ext%.*}"

trap_err_onexit()
{
if grep -q "'backend' and 'target' are mutually exclusive option. 'target' option automatically set a backend." "${filename}.log"; then
echo "${filename_ext} SUCCESS"
exit 0
fi

echo "${filename_ext} FAILED"
exit 255
}

trap trap_err_onexit ERR

rm -f ${filename}.log

# run test
onecc -C "dummy_cfg" -b "dummy_backend" -T "dummy_target" > ${filename}.log 2>&1

echo "${filename_ext} FAILED"
exit 255

0 comments on commit 8cf53ea

Please sign in to comment.