From 3312bfa2a134adec0d09213f4d0b4ca6b696829c Mon Sep 17 00:00:00 2001 From: gichan-jang Date: Tue, 1 Sep 2020 14:56:52 +0900 Subject: [PATCH] [Tizen.MachineLearning.Inference][TCSACR-365] Add TCs for getter and setter - uint64 Add TCs for GetValue and SetValue methods - uint64 Change-Id: I86715d049363c0db33538db002e542ee42574640 Signed-off-by: gichan-jang --- .../testcase/TSPipeline.NodeInfo.cs | 443 ++++++++++++++++++ 1 file changed, 443 insertions(+) diff --git a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSPipeline.NodeInfo.cs b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSPipeline.NodeInfo.cs index 2d8ff7490..8a85c82a2 100644 --- a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSPipeline.NodeInfo.cs +++ b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSPipeline.NodeInfo.cs @@ -2472,5 +2472,448 @@ namespace Tizen.MachineLearning.Inference.Tests { } } } + + [Test] + [Category("P1")] + [Description("Get unsigned long type value from tensor sink node and check exception")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("COVPARAM", "string, uint64")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void GetValue_ulong_NO_Exception() + { + try + { + var pipeline = new Pipeline(_generalPipeline); + Assert.IsNotNull(pipeline, "Failed to create pipeline instance"); + Assert.IsInstanceOf(pipeline, "Should return pipeline instance"); + + var sink_handle = pipeline.GetSink("sinkx"); + Assert.IsNotNull(sink_handle, "Failed to create normal node instance"); + Assert.IsInstanceOf(sink_handle, "Should return node instance"); + + /* Test Code */ + ulong retMaxBitrate; + sink_handle.GetValue("max-bitrate", out retMaxBitrate); + /* default value of max bitrate is 0 */ + Assert.IsTrue(retMaxBitrate == 0, "Failed to get the value of normal node"); + + pipeline.Dispose(); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.IsTrue(false, e.Message); + } + } + } + + [Test] + [Category("P2")] + [Description("Check ArgumentException when getting unsigned long type value of tensor sink node with null name")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, uint64")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void GetValue_ulong_ArgumentException_null_name() + { + try + { + var pipeline = new Pipeline(_generalPipeline); + Assert.IsNotNull(pipeline, "Failed to create pipeline instance"); + Assert.IsInstanceOf(pipeline, "Should return pipeline instance"); + + var sink_handle = pipeline.GetSink("sinkx"); + Assert.IsNotNull(sink_handle, "Failed to create normal node instance"); + Assert.IsInstanceOf(sink_handle, "Should return normal node instance"); + + /* Test Code */ + ulong retMaxBitrate; + sink_handle.GetValue(null, out retMaxBitrate); + + Assert.True(false, "DO NOT COME HERE!"); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.Fail(e.Message); + } + } + } + + [Test] + [Category("P2")] + [Description("Check ArgumentException when getting unsigned long type value of tensor sink node with invalid name")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, uint64")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void GetValue_ulong_ArgumentException_invalid_name() + { + try + { + var pipeline = new Pipeline(_generalPipeline); + Assert.IsNotNull(pipeline, "Failed to create pipeline instance"); + Assert.IsInstanceOf(pipeline, "Should return pipeline instance"); + + var sink_handle = pipeline.GetSink("sinkx"); + Assert.IsNotNull(sink_handle, "Failed to create normal node instance"); + Assert.IsInstanceOf(sink_handle, "Should return normal node instance"); + + /* Test Code */ + ulong retMaxBitrate; + sink_handle.GetValue("invalid_prop", out retMaxBitrate); + + Assert.True(false, "DO NOT COME HERE!"); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.Fail(e.Message); + } + } + } + + [Test] + [Category("P2")] + [Description("Check ArgumentException when getting unsigned long type value of tensor sink node with empty name")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, uint64")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void GetValue_ulong_ArgumentException_empty_name() + { + try + { + var pipeline = new Pipeline(_generalPipeline); + Assert.IsNotNull(pipeline, "Failed to create pipeline instance"); + Assert.IsInstanceOf(pipeline, "Should return pipeline instance"); + + var sink_handle = pipeline.GetSink("sinkx"); + Assert.IsNotNull(sink_handle, "Failed to create normal node instance"); + Assert.IsInstanceOf(sink_handle, "Should return normal node instance"); + + /* Test Code */ + ulong retMaxBitrate; + sink_handle.GetValue("", out retMaxBitrate); + + Assert.True(false, "DO NOT COME HERE!"); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.Fail(e.Message); + } + } + } + + [Test] + [Category("P2")] + [Description("Check ArgumentException when getting unsigned int type value of switch node with invalid retrun value")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, uint64")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void GetValue_ulong_ArgumentException_invalid_type() + { + try + { + string desc = "videotestsrc name=vsrc is-live=true ! videoconvert ! videoscale name=vscale ! " + + "video/x-raw,format=RGBx,width=224,height=224,framerate=60/1 ! tensor_converter ! " + + "valve name=valvex ! input-selector name=is01 ! tensor_sink name=sinkx"; + + var pipeline = new Pipeline(desc); + Assert.IsNotNull(pipeline, "Failed to create pipeline instance"); + Assert.IsInstanceOf(pipeline, "Should return pipeline instance"); + + var switch_handle = pipeline.GetSwitch("is01"); + Assert.IsNotNull(switch_handle, "Failed to create switch node instance"); + Assert.IsInstanceOf(switch_handle, "Should return normal switch instance"); + + /* Test Code */ + ulong retNumPad; + /* The type of n-pads is a uint, but it failed because it got property value by a ulong. */ + switch_handle.GetValue("n-pads", out retNumPad); + + Assert.True(false, "DO NOT COME HERE!"); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.Fail(e.Message); + } + } + } + + [Test] + [Category("P1")] + [Description("Set unsigned long type value for tensor sink node and check exception")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("COVPARAM", "string, uint64")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void SetValue_ulong_NO_Exception() + { + try + { + var pipeline = new Pipeline(_generalPipeline); + Assert.IsNotNull(pipeline, "Failed to create pipeline instance"); + Assert.IsInstanceOf(pipeline, "Should return pipeline instance"); + + var sink_handle = pipeline.GetSink("sinkx"); + Assert.IsNotNull(sink_handle, "Failed to create normal node instance"); + Assert.IsInstanceOf(sink_handle, "Should return normal node instance"); + + /* Test Code */ + ulong retMaxBitrate; + sink_handle.SetValue("max-bitrate", 123456789123456789UL); + sink_handle.GetValue("max-bitrate", out retMaxBitrate); + + Assert.IsTrue(retMaxBitrate == 123456789123456789UL, "Failed to get the value of normal node"); + + pipeline.Dispose(); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.IsTrue(false, e.Message); + } + } + } + + [Test] + [Category("P2")] + [Description("Check ArgumentException when setting unsigned long type value for tensor sink node with null name")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, uint64")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void SetValue_ulong_ArgumentException_null_name() + { + try + { + var pipeline = new Pipeline(_generalPipeline); + Assert.IsNotNull(pipeline, "Failed to create pipeline instance"); + Assert.IsInstanceOf(pipeline, "Should return pipeline instance"); + + var sink_handle = pipeline.GetSink("sinkx"); + Assert.IsNotNull(sink_handle, "Failed to create normal node instance"); + Assert.IsInstanceOf(sink_handle, "Should return normal node instance"); + + /* Test Code */ + sink_handle.SetValue(null, 123456789123456789UL); + + Assert.True(false, "DO NOT COME HERE!"); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.Fail(e.Message); + } + } + } + + [Test] + [Category("P2")] + [Description("Check ArgumentException when setting unsigned long type value for tensor sink node with invalid name")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, uint64")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void SetValue_ulong_ArgumentException_invalid_name() + { + try + { + var pipeline = new Pipeline(_generalPipeline); + Assert.IsNotNull(pipeline, "Failed to create pipeline instance"); + Assert.IsInstanceOf(pipeline, "Should return pipeline instance"); + + var sink_handle = pipeline.GetSink("sinkx"); + Assert.IsNotNull(sink_handle, "Failed to create normal node instance"); + Assert.IsInstanceOf(sink_handle, "Should return normal node instance"); + + /* Test Code */ + sink_handle.SetValue("invalid_prop", 123456789123456789UL); + + Assert.True(false, "DO NOT COME HERE!"); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.Fail(e.Message); + } + } + } + + [Test] + [Category("P2")] + [Description("Check ArgumentException when setting unsigned long type value for tensor sink node with empty name")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, uint64")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void SetValue_ulong_ArgumentException_empty_name() + { + try + { + var pipeline = new Pipeline(_generalPipeline); + Assert.IsNotNull(pipeline, "Failed to create pipeline instance"); + Assert.IsInstanceOf(pipeline, "Should return pipeline instance"); + + var sink_handle = pipeline.GetSink("sinkx"); + Assert.IsNotNull(sink_handle, "Failed to create normal node instance"); + Assert.IsInstanceOf(sink_handle, "Should return normal node instance"); + + /* Test Code */ + sink_handle.SetValue("", 123456789123456789UL); + + Assert.True(false, "DO NOT COME HERE!"); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.Fail(e.Message); + } + } + } + + [Test] + [Category("P2")] + [Description("Check ArgumentException when setting unsigned int type value for normal node with invalid name")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, uint64")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void SetValue_ulong_ArgumentException_invalid_type() + { + try + { + string desc = "videotestsrc name=vsrc is-live=true ! videoconvert ! videoscale name=vscale ! " + + "video/x-raw,format=RGBx,width=224,height=224,framerate=60/1 ! tensor_converter ! " + + "valve name=valvex ! input-selector name=is01 ! tensor_sink name=sinkx"; + + var pipeline = new Pipeline(desc); + Assert.IsNotNull(pipeline, "Failed to create pipeline instance"); + Assert.IsInstanceOf(pipeline, "Should return pipeline instance"); + + var vsrc_node = pipeline.GetNormal("vsrc"); + Assert.IsNotNull(vsrc_node, "Failed to create normal node instance"); + Assert.IsInstanceOf(vsrc_node, "Should return normal node instance"); + + /* Test Code */ + /* The type of foreground-color is a uint, but it failed because it was set as a ulong. */ + vsrc_node.SetValue("foreground-color", 123456789UL); + + Assert.True(false, "DO NOT COME HERE!"); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.Fail(e.Message); + } + } + } } } -- 2.34.1