190792Sgshapiro/*
2261363Sgshapiro * Copyright (c) 2000-2002 Proofpoint, Inc. and its suppliers.
390792Sgshapiro *	All rights reserved.
490792Sgshapiro *
590792Sgshapiro * By using this file, you agree to the terms and conditions set
690792Sgshapiro * forth in the LICENSE file which can be found at the top level of
790792Sgshapiro * the sendmail distribution.
890792Sgshapiro */
990792Sgshapiro
1090792Sgshapiro#include <sm/gen.h>
11266692SgshapiroSM_IDSTR(id, "@(#)$Id: t-fopen.c,v 1.10 2013-11-22 20:51:43 ca Exp $")
1290792Sgshapiro
1390792Sgshapiro#include <fcntl.h>
1490792Sgshapiro#include <sm/io.h>
1590792Sgshapiro#include <sm/test.h>
1690792Sgshapiro
1790792Sgshapiro/* ARGSUSED0 */
1890792Sgshapiroint
1990792Sgshapiromain(argc, argv)
2090792Sgshapiro	int argc;
2190792Sgshapiro	char *argv[];
2290792Sgshapiro{
2394334Sgshapiro	int m, r;
2490792Sgshapiro	SM_FILE_T *out;
2590792Sgshapiro
2690792Sgshapiro	sm_test_begin(argc, argv, "test sm_io_fopen");
2790792Sgshapiro	out = sm_io_fopen("foo", O_WRONLY|O_APPEND|O_CREAT, 0666);
2890792Sgshapiro	SM_TEST(out != NULL);
2990792Sgshapiro	if (out != NULL)
3090792Sgshapiro	{
3190792Sgshapiro		(void) sm_io_fprintf(out, SM_TIME_DEFAULT, "foo\n");
3294334Sgshapiro		r = sm_io_getinfo(out, SM_IO_WHAT_MODE, &m);
3394334Sgshapiro		SM_TEST(r == 0);
3494334Sgshapiro		SM_TEST(m == SM_IO_WRONLY);
3590792Sgshapiro		sm_io_close(out, SM_TIME_DEFAULT);
3690792Sgshapiro	}
3790792Sgshapiro	return sm_test_end();
3890792Sgshapiro}
39