From d3b9d11369ee15dc0ce512014284c3c5432f2813 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 13 Feb 2013 08:22:07 -0800 Subject: [PATCH] Add a test that getaddrinfo works when hints are NULL. Bug: 1827911 Change-Id: I9e1b774c44c10a8c5391bcf3baf1607f50eaf214 --- tests/Android.mk | 1 + tests/netdb_test.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/netdb_test.cpp diff --git a/tests/Android.mk b/tests/Android.mk index 8138cff7c..eb97e6cc1 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -63,6 +63,7 @@ test_src_files = \ getcwd_test.cpp \ libgen_test.cpp \ math_test.cpp \ + netdb_test.cpp \ pthread_test.cpp \ regex_test.cpp \ signal_test.cpp \ diff --git a/tests/netdb_test.cpp b/tests/netdb_test.cpp new file mode 100644 index 000000000..168f7c148 --- /dev/null +++ b/tests/netdb_test.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * 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. + */ + +#include + +#include +#include +#include + + +TEST(netdb, getaddrinfo_NULL_hints) { + addrinfo* ai = NULL; + ASSERT_EQ(0, getaddrinfo("localhost", "9999", NULL, &ai)); + freeaddrinfo(ai); +}