get_item.c revision 72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7
/* liblxcapi
*
* Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>.
* Copyright © 2012 Canonical Ltd.
*
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "../lxc/lxccontainer.h"
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define MYNAME "lxctest1"
{
struct lxc_container *c;
int ret;
ret = 1;
goto out;
}
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
#define HNAME "hostname1"
// demonstrate proper usage:
char *alloced;
ret = 1;
goto out;
}
int len;
if (len < 0) {
ret = 1;
goto out;
}
// allocate the length of string + 1 for trailing \0
if (!alloced) {
ret = 1;
goto out;
}
// now pass in the malloc'd array, and pass in length of string + 1: again
// because we need room for the trailing \0
if (ret < 0) {
ret = 1;
goto out;
}
ret = 1;
goto out;
}
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
// new test with real container
ret = 1;
goto out;
}
c->destroy(c);
ret = 1;
goto out;
}
ret = 1;
goto out;
}
/* XXX TODO load_config needs to clear out any old config first */
ret = 1;
goto out;
}
ret = 1;
goto out;
}
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
ret = 1;
goto out;
}
if (ret <= 0) {
ret = 1;
goto out;
}
if (!c->clear_config_item(c, "lxc.network.0.ipv4")) {
ret = 1;
goto out;
}
if (ret != 0) {
fprintf(stderr, "%d: after clearing ipv4 entries get_item(lxc.network.0.ipv4 returned %d\n", __LINE__, ret);
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
if (!c->clear_config_item(c, "lxc.network")) {
ret = 1;
goto out;
}
if (ret != 0) {
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
if (ret < 0) {
ret = 1;
goto out;
}
if (!c->clear_config_item(c, "lxc.cgroup")) {
ret = 1;
goto out;
}
if (!c->clear_config_item(c, "lxc.cap.drop")) {
ret = 1;
goto out;
}
if (!c->clear_config_item(c, "lxc.mount.entries")) {
ret = 1;
goto out;
}
if (!c->clear_config_item(c, "lxc.hook")) {
ret = 1;
goto out;
}
c->destroy(c);
printf("All get_item tests passed\n");
ret = 0;
out:
};